Forum Moderators: open
I have a query such as
SELECT h.id AS id, h.name AS name, hl.id AS hl_id, hl.date AS date
FROM (table1 AS h, table2 AS hl)
WHERE hl.id = h.id
ORDER BY date DESC LIMIT 100
This query takes about 0.08seconds
when I repeat the same query such as
SELECT h.id AS id, h.name AS name, hl.id AS hl_id, hl.date AS date
FROM (table1 AS h, table2 AS hl)
WHERE hl.id = h.id
ORDER BY id DESC LIMIT 100
This query takes as much as 28 to 49 seconds.
In this second example I am ordering on table1.id
Noteworthy:
1. both the table.id and table2.date are indexs (respectively)
2. Each table has almost the same number of records.
Why is this query taking so much longer?
--