14/07/2020

The archive contains older posts which may no longer reflect my current views.

# I think I found what was causing the performance issues with On this day. I've always checked the year of the oldest post so that it only checks for the period when there might actually be posts - run a quick query to get the oldest post then get the year:

$args = array('orderby'=>'date','order=>'ASC','posts_per_page'=>1);
$oldestpost = get_posts($args);
$oldestyear = mysql2date('Y',$oldestpost[0]->post_date);

The thing is, the oldest post is never going to change. I replaced the above with just $oldestyear = 2008; and things now work much faster.

I still don't understand what changed and why that query should suddenly cause such an issue. Maybe there's some kind of threshold been reached with the number of posts get_posts() will handle efficiently. I'll have to do a search.

# I can't find anything about efficiency limits with get_posts() so who knows...