MySQL slow query - “Waiting for query cache lock”

后端 未结 2 1624
小鲜肉
小鲜肉 2020-12-14 02:35

I am running a simple query on a simple table on the same machine as the server running 5.5. It is taking 22sec to return ~7000 rows from a 20 million row table. Upon prof

2条回答
  •  难免孤独
    2020-12-14 02:51

    I solved my slow query problem. To summarize the problem, it was taking 22sec to query 7000 rows from a 20mln row, 1.7GB indexed table. The problem was that the cache was too small and the query had to go to disk for every query. I would think the disk access would be faster than what I was seeing because I was going off an indexed column so the amount of data read off disk should have been small. But I'm guessing there is a lot of overhead with accessing the InnoDB storage on disk.

    Once I set innodb_buffer_pool_size=1024M in the my.ini file, the initial query would take a long time, but all subsequent queries would finish in under a second.

    Unfortunately, the profiling didn't really help.

提交回复
热议问题