To avoid making code changes every time we have a database change, we just use the SHOW FIELDS (Alias of SHOW COLUMNS) to get all of the columns for Inserts. We call this multiple times for multiple tables in various scripts.
Recently we have discovered speed issues so we started to look at the temp table disk report and found that the SHOW FIELDS FROM 'sometable' all had 100% hits to the disk temp table.
I've tried turning up our query cache size (yes it is enabled), and I've disabled the meta calculations 'SET GLOBAL innodb_stats_on_metadata = OFF;'
We are still getting 100% disk temp table hits on all of these show queries. Is there an easy way to fix these without a code change? We would like to still do our inserts without updating the columns in the code, and the SHOW FIELDS call is part of a framework and we would like to avoid rewriting it if possible.
Thanks
Best Answer
Would you consider a RAM disk for temp tables ?
First, create the RAM disk (16GB)
Next, add this to
my.cnf
Then, just restart mysql
Now, all temp tables will land in RAM
I have discussed this before
Oct 09, 2012
: Inserting query result to another table hangs on "Copying to temp table on disk" on MySQLNov 30, 2012
: Is it bad to create many mysql temporary tables simultaneously?Jan 04, 2013
: Is there a MySQL engine or trick to avoid writing so many temp tables to disk?Nov 15, 2013
: MySQL creates temporary tables on disk. How do I stop it?Give it a Try !!!