开发者

Mysql - Aggregate function is very slow

I have a mysql database with very large tables. I often run queries that involve aggregate functions. Queries开发者_如何学Go with the aggregate functions like MIN, MAX, SUM, COUNT are running very slow. Please help me to increase the speed.

SELECT MIN(PeriodTime) FROM ResultsTable WHERE (OrderId=271)
SELECT COUNT(*) FROM ResultsTable WHERE (OrderId=271);  ==> returns 258021

Total rows in that table = 1213284, My Query matches = 258021 rows.

I appreciate any help. Thank you.


Create an index on ResultsTable that covers PeriodTime and OrderId. That will help a lot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜