M
M
maksam072021-10-08 11:05:57
MySQL
maksam07, 2021-10-08 11:05:57

How to speed up SELECT where all rows need to be retrieved except for one?

Good afternoon. I have a wordpress request like this:

SELECT ID, user_login
FROM users
WHERE ID != '81306'
ORDER BY user_login ASC

The request is written by a plug-in and I do not want to climb into it. But I do small optimizations on the database, as far as I have enough knowledge, but here I stalled. Indexes on id and user_login are registered separately. The query execution time is not very critical, but nevertheless - 0.1625
Can I speed it up somehow or will I have to live with such a plugin?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Kazantsev, 2021-10-08
@saintbyte

Do an index by user_login - IMHO sorting by field slows down

T
ThunderCat, 2021-10-08
@ThunderCat

to begin with explain, understand what and how, then look towards composite indexes. The absence of limit is also slightly surprising, in this way you select the entire contents of the table, which cannot but affect the sampling speed. Also, the length of the key for the (obviously) text field (indicate the type by the way, I hope there is a limited varchar, not a longtext or a blob ...) should cover the possible length of the login well.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question