Out of memory (Needed 129032 bytes). SELECT YEAR(publishing_date) AS year, DATE_FORMAT(publishing_date, "%m") AS month, COUNT(1) AS amount FROM fir_news WHERE is_published = 1 GROUP BY DATE_FORMAT(publishing_date, "%Y-%m") ORDER BY publishing_date DESC