I have tried to order by id desc and now it works fine, the query is very fast.
Why is it faster for the id than for the created_at field ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have a table with 600 000 lines.
I need to retrieve the last 10 lines (created_at) every second.
The query takes about 10 seconds to be executed from the application.
When I execute the same query directly inside phpmyadmin, it takes about 3 to 5 seconds.
The table has only 4 fields : id, content, created_at, updated_at.
The created_at field is indexed.
What could be the problem ?
Thanks for your help.
V
@vincent15000 If the index is properly created it should not matter that much, but of course a sequential index is faster than a date time one.
Please or to participate in this conversation.