“SELECT COUNT(*)” is slow, even with where clause

后端 未结 8 1631
抹茶落季
抹茶落季 2020-11-30 23:22

I\'m trying to figure out how to optimize a very slow query in MySQL (I didn\'t design this):

SELECT COUNT(*) FROM change_event me WHERE change_event_id >         


        
8条回答
  •  生来不讨喜
    2020-11-30 23:56

    I've run into behavior like this before with IP geolocation databases. Past some number of records, MySQL's ability to get any advantage from indexes for range-based queries apparently evaporates. With the geolocation DBs, we handled it by segmenting the data into chunks that were reasonable enough to allow the indexes to be used.

提交回复
热议问题