Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:32:00+00:00 2026-05-25T20:32:00+00:00

I have a question for large mysql queries. Is it possible to skip the

  • 0

I have a question for large mysql queries. Is it possible to skip the copying to tmp table on disk step that mysql takes for large queries or is it possible to make it go faster? because this step is taking way too long to get the results of my queries back. I read on the MySQL page that mysql performs this to save memory, but I don’t care about saving memory I just want to get the results of my queries back FAST, I have enough memory on my machine. Also, my tables are properly indexed so that’s not the reason why my queries are slow.

Any help?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:32:00+00:00Added an answer on May 25, 2026 at 8:32 pm

    There are two things you can do to lessen the impact by this

    OPTION #1 : Increase the variables tmp_table_size and/or max_heap_table_size

    These options will govern how large an in-memory temp table can be before it is deemed too large and then pages to disk as a temporary MyISAM table. The larger these values are, the less likely you will get ‘copying to tmp table on disk’. Please, make sure your server has enough RAM and max_connections is moderately configured should a single DB connection need a lot of RAM for its own temp tables.

    OPTION #2 : Use a RAM disk for tmp tables

    You should be able to configure a RAM disk in Linux and then set the tmpdir in mysql to be the folder that has the RAM disk mounted.

    For starters, configure a RAM disk in the OS

    Create a folder in the Linux called /var/tmpfs

    mkdir /var/tmpfs
    

    Next, add this line to /etc/fstab (for example, if you want a 16GB RAM disk)

    none                    /var/tmpfs              tmpfs   defaults,size=16g        1 2
    

    and reboot the server.

    Note : It is possible to make a RAM disk without rebooting. Just remember to still add the aforementioned line to /etc/fstab to have the RAM disk after a server reboot.

    Now for MySQL:

    Add this line in /etc/my.cnf

    [mysqld]
    tmpdir=/var/tmpfs
    

    and restart mysql.

    OPTION #3 : Get tmp table into the RAM Disk ASAP (assuming you apply OPTION #2 first)

    You may want to force tmp tables into the RAM disk as quickly as possible so that MySQL does not spin its wheels migrating large in-memory tmp tables into a RAM disk. Just add this to /etc/my.cnf:

    [mysqld]
    tmpdir=/var/tmpfs
    tmp_table_size=2K
    

    and restart mysql. This will cause even the tiniest temp table to be brought into existence right in the RAM disk. You could periodically run ls -l /var/tmpfs to watch temp tables come and go.

    Give it a Try !!!

    CAVEAT

    If you see nothing but temp tables in /var/tmpfs 24/7, this could impact OS functionality/performance. To make sure /var/tmpfs does not get overpopulated, look into tuning your queries. Once you do, you should see less tmp tables materializing in /var/tmpfs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large mysql table that I think might be using the wrong
Question We have a large number of xml configuration files that we want merged
We have a large MyISAM table that is used to archive old data. This
I have a data table with 600,000 records that is around 25 megabytes large.
I have a MySQL indexing question for you guys. I've got a very large
I have been starting to write some reasonably large and or confusing MySQL queries
I have a ~10M record MySQL table that I interface with using SqlAlchemy. I
I have a question about MySql. I have a table with 7.479.194 records. Some
Swing newbie question... I have a system where there is a large number of
This may be a silly question, but right now I have a rather large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.