how to reduce mysql slow query time for big database
I have almost 5 gb database on my mysql 5.5 myisam. My os architecture is fedora 64 bit. Now I if I do single query from the table which holding large data query is being slow for more than 3开发者_Go百科0 sec. Can any one please tell me how can I reduce the slow query? I have 2 gb memory and 6 gb swap. [updated] slow log out put is here
# Query_time: 19.367274 Lock_time: 0.000109 Rows_sent: 54 Rows_examined: 4263723
SET timestamp=1310052008;
SELECT timestamp FROM nse_data WHERE symbol='NIFTY'AND series='IN' AND timestamp BETWEEN '2011-04-07' AND '2011-07-07' ORDER BY timestamp;
Thanks
Every query is very different, but at first glance it seems that this particular query can run fastest with this index:
ALTER TABLE `nse_data` ADD INDEX `index_nse_data` (`timestamp` ASC, `symbol` ASC, `series` ASC);
Of course, it's just a guess, because I don't know anything about your data :)
The first thing to try is to add indexes for the columns you regularly search/order on.
精彩评论