MySQL incorrect key file for tmp table when making multiple joins

后端 未结 11 1267
轻奢々
轻奢々 2020-11-27 17:01

I don\'t come here for help often but I am pretty frustrated by this and I am hoping someone has encountered it before.

Whenever I try to fetch records from a table

11条回答
  •  臣服心动
    2020-11-27 17:29

    You may find running "ANALYZE TABLE " helps.

    We had this problem suddenly appear on a large table (~100M rows) and MySQL tried to use /tmp to write a temporary table of over 1GB, which failed as /tmp was limited to ~600M.

    It turned out that the statistics for the InnoDB table were rather stale. After running "ANALYZE TABLE ...", the statistics were updated and the problem cleared. With the more accurate statistics, MySQL was able to optimize the query correctly and the large tmp file was no longer required.

    We now run "mysqlcheck -Aa" periodically to keep all table statistics fresh.

提交回复
热议问题