MySQL Query IN() Clause Slow on Indexed Column

前端 未结 5 456
自闭症患者
自闭症患者 2020-12-03 01:18

I Have a MySQL query that is being generated by a PHP script, the query will look something like this:

SELECT * FROM Recipe_Data WHERE 404_Without_200 = 0 A         


        
5条回答
  •  鱼传尺愫
    2020-12-03 01:56

    You are accessing 420 rows by primary key which will probably lead to an index access path. This could access 2 index pages and one data page per key. If these are in cache, the query should run fast. If not, every page access that goes to disk will incur the usual disk latency. If we assume 5ms disk latency and 80% cache hits, we arrive at 420*3*0.2*5ms=1.2 seconds which is on the order of what you're seeing.

提交回复
热议问题