There is a request that is executed 7 seconds. Records in the table img about 10k.
SELECT img.id,date,title,url,views,votes,values,name FROM img INNER JOIN img_views ON img.id = img_views.m INNER JOIN img_rating ON img.id = img_rating.m INNER JOIN users ON img.user = users.id WHERE status = '1' ORDER BY img.id DESC LIMIT 0, 10 By tests I found out that the brakes come from INNER JOIN img_views и INNER JOIN img_rating . These tables store data on the rating of records and the number of views, 10k in each table.
Is there a way to optimize the query? And does it make sense to store data on the ranking of records and the number of views in other tables? Tables in InnoDB.
ON. Andstatusis what is your table. It is impossible to give recommendations without understanding why views and rating are created for example, and what kind of load they still carry besides storing some columns, which in this query are not even visible from where - Mikeset VIEWS=VIEWS+1, that is, the table block, will it affect performance? - Rufex