Answer the question
In order to leave comments, you need to log in
MySQL: Sorting by primary key or index?
Started optimizing the database. Approached to studying of a question of indexes in MySQL.
As you know, the capacity of queries is determined by the EXPLAIN command.
There is a table ID MEMBER VIP
Query: SELECT * FROM vip WHERE member='1'
The explain command shows rows - 8500 . That is, to execute the request, you have to check all the rows.
It turns out that I need to set an index on the member field and the problem will be solved.
But! Why with such a request
SELECT * FROM vip WHERE member='1' ORDER BY id DESC LIMIT 0,1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question