Incorrect key file with MySQL

前端 未结 3 916
太阳男子
太阳男子 2021-01-18 08:35

I\'m having a problem with a InnoDB (table was initally MyISAM, but converted it to InndoB awhile ago) table; I am trying to run this query:

SELECT 
   posts         


        
3条回答
  •  渐次进展
    2021-01-18 08:53

    What's going on here is MySQL is doing the ORDER BY by building a temporary table from the join of the two tables. The temporary table is too large to fit into memory so MySQL creates a temporary file.

    There are a few thing that would prevent this from working correctly. Raw disk space is one. ulimit is another. If this is being hosted, they may have a quota on your disk usage (in addition to ulimit).

    I would suggest adding a limiting clause to your query. Currently you load the entire of both the rss_posts and rss_feeds into the temporary table for sorting. If you only want the most recent 10 that's a lot more data than you really need.

    SELECT posts.id, posts.post_title 
    FROM rss_posts AS posts INNER JOIN rss_feeds AS feeds ON posts.blog_id=feeds.id 
    WHERE feeds.blog_language=1 
    AND posts.post_data_db > (now - interval 30 day);
    ORDER BY posts.post_date_db DESC LIMIT 10;
    

提交回复
热议问题