B
B
BonBon Slick2017-04-22 17:24:21
MySQL
BonBon Slick, 2017-04-22 17:24:21

Why is possible_keys NULL when they are in the right order?

Here is the request:

EXPLAIN select SQL_NO_CACHE `id`, `title`, `alias`, `content`, `published_at`, `image`, `thumb`, `parent_folder_id` from `slc_articles` order by `sticked` desc, `published_at` desc limit 21

Indexes:
31eae962b4a94681b2c8f7a515a13d15.pngBut it does not use them:
6013bd6ea5ac4048abe56eca0b1291d0.png
Perhaps because I put a 1-in composite index on everything, perhaps if I make several different ones for each query, will the muscle automatically select the desired index?
Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-04-22
@BonBonSlick

MySQL can only use an index if the fetch or sort starts on the first column of the index. Your query must have an index whose first column is `sticked`.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question