{"id":7474704,"date":"2016-06-14T11:22:29","date_gmt":"2016-06-14T11:22:29","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/how-expensive-is-the-summary-query\/"},"modified":"2016-09-01T15:33:41","modified_gmt":"2016-09-01T15:33:41","slug":"how-expensive-is-the-summary-query","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/how-expensive-is-the-summary-query\/","title":{"rendered":"how expensive is the summary query?"},"content":{"rendered":"<p>Hi,<br \/>\njust curious as to how expensive this query is?<\/p>\n<pre><code>$months    = $wpdb-&gt;get_results( &quot;SELECT DISTINCT MONTH( post_date ) AS month , YEAR( post_date ) AS year, COUNT( id ) as post_count FROM $wpdb-&gt;posts WHERE post_status = &#039;publish&#039; and post_date &lt;= now( ) and post_type = &#039;post&#039; GROUP BY month , year ORDER BY post_date DESC&quot; );<\/code><\/pre>\n<p>Given that the result of this query will change rarely, would there be any advantage in push \/ pulling it from a transient, instead of re-executing it on each page load that contains the widget? Just a thought&#8230;<br \/>\ncheers,<br \/>\nHugh<\/p>\n<p>https:\/\/wordpress.org\/plugins\/expanding-archives\/<\/p>\n","protected":false},"template":"","class_list":["post-7474704","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7474704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7474704\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=7474704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}