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

后端 未结 8 1607
抹茶落季
抹茶落季 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:57

    Check to see how fragmented your indexes are. At my company we have a nightly import process that trashes our indexes and over time it can have a profound impact on data access speeds. For example we had a SQL procedure that took 2 hours to run one day after de-fragmenting the indexes it took 3 minutes. we use SQL Server 2005 ill look for a script that can check this on MySQL.

    Update: Check out this link: http://dev.mysql.com/doc/refman/5.0/en/innodb-file-defragmenting.html

提交回复
热议问题