Answer the question
In order to leave comments, you need to log in
What is the correct way to use Explain in MySQL?
Hello.
I decided to calculate slow queries in the slow_query_log muscle .
I found one, on the test database of records in this table 90k+:
SELECT * FROM `Article`
WHERE `Article`.`type` = '1'
AND `Article`.`status` = '1'
AND `Article`.`publish_t` < '1529399940'
AND `Article`.`fixed_t` > '1529399940'
GROUP BY `Article`.`fixed_place`
ORDER BY `Article`.`fixed_t` ASC;
The type column of EXPLAIN output describes how tables are joined. The following list describes the join types, ordered from the best type to the worst:
Answer the question
In order to leave comments, you need to log in
Because now it has become easier to select the necessary rows by the fixed_t index than by the status index.
Compare:
and
The fewer lines that match the condition, the better. And type = range in the second case - because you choose not the exact value, but from the given value to infinity.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question