Home > database > Found a strange question. Mysql in explain the type of the efficiency of the index is higher than th
Found a strange question. Mysql in explain the type of the efficiency of the index is higher than th
Time:09-17
Table structure:
SQL: The SELECT vod_id FROM ` ia_comment ` where vod_id & gt; 0 and account_id=88; The SELECT vod_id FROM ` ia_comment ` where account_id=88; Results: SELECT [SQL] vod_id FROM ` ia_comment ` where vod_id & gt; 0 and account_id=88; The affected line: 0 Time: 0.323 s
[SQL] The SELECT vod_id FROM ` ia_comment ` where account_id=88; The affected line: 0 Time: 0.152 s
Why the second SQL instead of scanning the rows of more efficiency higher Data from two SQL is the same as Vod_id all greater than 0
CodePudding user response:
Which version are you using MySQL?
CodePudding user response:
Execution plan, just reference, not necessarily accurate, A lot of time, the implementation of planned, the efficiency is not necessarily good,
CodePudding user response:
Note key_len, the first SQL is 4 that only joint vod_id index of the first column, so vod_id this index is used only for vod_id & gt; 0 selection, read from the index data, and carries on the account_id=88 judgment, slow is slow in another judgment more account_id=88; And the second key_len is 8, that is, directly in the where clause for judging index, So the second will be a bit faster,
CodePudding user response:
Why possible_key is empty, the key is empty, not seen, extra content is not complete, difficult to determine the further,