EXPLAIN SELECT *
From ' Order2 '
WHERE 1
ORDER by ' Create_time ' DESC
Full table Scan ...
Reply to discussion (solution)
The index in order doesn't work that way.
Your condition is the full table, no matter what index will be the whole table to come again
I understand that the order index should be used in two places.
1. When there is limit
2.order field in the Select return value, this is more complex, that is, only the Order field in the return, or return several fields, the index must be a combination of these fields in the order of the index
The index in order doesn't work that way.
Your condition is the full table, no matter what index will be the whole table to come again
I understand that the order index should be used in two places.
1. When there is limit
2.order field in the Select return value, this is more complex, that is, only the Order field in the return, or return several fields, the index must be a combination of these fields in the order of the index
I just used the order index as if it worked, strange, is there garbage data that affects the index of the entire table? (different libraries, different tables)
Add an index condition such as EXPLAIN SELECT *
From ' Order2 '
WHERE 1 and Create_time>0
ORDER by ' Create_time ' DESC
Remember, if your table data cardinality is too small, or the distribution is not large, the MySQL query optimizer will remove the index, perform a full table scan.
This automatic optimization behavior is not predictable, so when the amount of data is small, sometimes the index does not
Remember, if your table data cardinality is too small, or the distribution is not large, the MySQL query optimizer will remove the index, perform a full table scan.
This automatic optimization behavior is not predictable, so when the amount of data is small, sometimes the index does not
Yes, I found this problem.
And there's too much data on the search condition to scan the whole table.