ORDER BY clause slows down query
I have these two tables.
Products:
Assets:
Result with ORDER BY clause return in 44 seconds.
SELECT p.id, i.filepath, p.TotalDownloads
FROM products p
INNER JOIN assets i ON i.hash=p.product_id
WHERE p.Name like '%rar%' AND i.format='ico'
ORDER by p.TotalDownloads DESC
LIMIT 0, 10
Showing rows 0 - 9 (10 total, Query took 44.0769 seconds.) [TotalDownloads: 164554096... - 724290...]
AND without ORDER BY clause, results return in 1 second.
SELECT p.id, i.filepath, p.TotalDownloads
FROM products p
INNER JOIN assets i ON i.hash=p.product_id
WHERE p.Name like '%rar%' AND i.format='ico'
LIMIT 0, 10
Showing rows 0 - 9 (10 total, Query took 1.0668 seconds.)
from Recent Questions - Stack Overflow https://ift.tt/ohbKCOy
https://ift.tt/FBsij7f
Comments
Post a Comment