I have a table tb_profilecomments:
4,3 GiB -- 8 Million rows total -- InnoDB
with 3 indexes:
The query I run is simple:
SELECT *
FROM tb_profilecomments
WHERE profilecomment_user_id=6430
ORDER BY profilecomment_id DESC
Getting a result in less than 1 second (16.000+ rows).
When I now add LIMIT 1, 5
to the query then I got to wait more than 2 minutes to get a result.
Don't know what happens in the mysql background why it's slowing down the query so heavily.
When I remove ORDER BY
or LIMIT
from the query, then everything is fine.
When sorting it by non-indexed profilecomment_date
column, then it's slow (7 seconds), but not 2 minutes like when sorting and limiting with the indexed primary key profilecomment_id
.
Do you have any idea what's wrong? A broken index maybe? How to find out? How to fix? ANALYZE TABLE says message "ok".
EXPLAIN tb_profilecomments:
SHOW CREATE TABLE tb_profilecomments:
Result EXPLAIN SELECT * FROM tb_profilecomments WHERE profilecomment_user_id=6430 ORDER BY profilecomment_id DESC LIMIT 1, 5
: