php - mysql query optimization problem?
大家讲道理
大家讲道理 2017-05-16 13:08:33
0
2
506
select count(*) as aggregate from `call_records` where (`CallType` = 'dialout' and `CalledNo` = '12345678910');

How to optimize this query? The premise is that the index cannot be created, because there are already several indexes in this table, which may cause the table to be locked.

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
给我你的怀抱

Is it hot data? If not, just make a script to run regularly and save the statistical count into another statistical table.
For hot data, see if the index you built before can be turned into a combined index. Because the B-tree starts from the left, if you build an (a, b, c), a and a, b and a, b, and c can be used. Used, the query function at the code layer pays attention to the field order.

PHPzhong

Re-optimize the index. There are too many single indexes, so try to build a joint index. If this statistics does not require real-time performance, use md5 (sql statement) as the key, use the result as the value, and store it in the cache (redis).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template