I have the following MSQL query, that is very slow
SELECT a.id, a.date, a.Title, a.Text, a.Text2, a.Text3,
b.xxx, b.yyyy,
c.aaaa, c.bbbb
FROM table_a a
JOIN table_b b on a.Id = b.Id
JOIN table_c c on a.eeee = c.id
ORDER BY a.date DESC
LIMIT 200
The table_a has more that 100.000 rows. I need the last 200 rows in reverse order. What MySQL does is to select all rows, made the JOIN of all rows, then reverse the full table and finally select 200 record. The full process takes about 30-40 seconds.
Question: since table_a is ordered by a.id (it is a progressive number) and also by date (new articles are always added in the last position), is it possible to rewrite the query so that the JOIN is performed only on the latest 200 records and not the full table ? In this way the query will be much faster!
In general, how can be optimized ??
You can try this, but i am not realy sure if LIMIT is allowed.