Besides this suggestion, here is a simple SQL
query adapted from the core wp_get_archives
function:
SELECT
YEAR(post_date) AS `year`,
MONTH(post_date) AS `month`,
count(ID) as posts
FROM
wp_posts
WHERE
post_type="post" AND post_status="publish"
GROUP BY
YEAR(post_date), MONTH(post_date)
ORDER BY
post_date DESC
This would provide with a structure like this:
+------+-------+-------+
| year | month | posts |
+------+-------+-------+
| 2015 | 5 | 1 |
| 2015 | 4 | 1 |
+------+-------+-------+
You can use $wpdb->get_results
for this query.