There is a table users
. It has 500,000 users. It is necessary to optimize the query selection of users with regard to sorting by first_name
, last_name
, etc.
My query looks like this:
SELECT `user_id`, `first_name`, `last_name`, `city_name`, `password`, `post_index`, `birthdate`, `salary` FROM `users` ORDER BY last_name ASC LIMIT 0, 300
But the problem is that it runs for 1 minute and 8 seconds on my computer.
Tell me what you can do.