There is a news site, news is divided into sections. How to display in one query N records for each section? Read here
I tried this query:
SELECT a.* FROM content_content AS a LEFT JOIN content_content AS a2 ON a.news_section_id = a2.news_section_id AND a.pub_date <= a2.pub_date GROUP BY a.title HAVING COUNT(*) <= 3 ORDER BY a.news_section_id, a.pub_date DESC;
But after 10 minutes of inactivity, Muscle loses connection. I expected almost instant performance. What am I doing wrong?