I have two tables: posts
and categories
.
The posts table
has about 360,000 lines
.
I want to show only the first post of each category, ordering by date and using pagination.
The query:
SELECT * FROM
(SELECT * FROM posts ORDER BY date_post DESC) as temp
GROUP BY id_category ORDER BY date_post DESC
LIMIT $offset, $limit"
The query is taking about 1 minute to load and show my site.
I've tried changing MyISAM to InnoDB and use partitions whithout success.
The server that the website is being hosted is a dedicated server, and I believe that the problem is not it.
Anyone have some suggestions?