Post Query Accelerator

About

WordPress’ post queries always ask for posts with post_date_gmt <= '$now' where $now is set to the current time, to prevent posts in the future from showing up. This means that $now changes with each page load. For high volume MySQL sites, the system administrator might turn on MySQL’s qcache, in order to cache some SQL queries. The problem with $now is that it changes each time, so the query is never exactly the same again, and the cache doesn’t help. This plugin is designed to freeze $now to reflect the time of the most recent post or page. This does the job of preventing future posts from showing up, but doesn’t needlessly change $now on every load. This can lead to rather large query speedups on high volume sites or sites with many posts. If things like qcache and my.cnf are Greek to you, please don’t use this plugin. Those who need this plugin will know that they need it, and without a properly configured my.cnf with query caching, it will do nothing.

Download

Instructions

Download and save in a file named post-query-accelerator.php. Upload to your /wp-content/plugins/ directory. Activate it from within the WordPress admin interface.

Notes

The value of $now is updated whenever you edit/save/publish an entry. But to allow for future dated posts to show up at their scheduled time, the plugin also checks once every 15 minutes to see if it’s time for any new posts to show up. Because of this, a post scheduled to show up at 7:00am might not show up until 7:15am (at the very latest). If a post doesn’t show up and you’re expecting it to be there, give it 15 minutes.

Update

I’m happy to say that when WordPress 2.1 is released, this plugin will no longer be needed. WordPress 2.1 uses a special status of “future” for all posts in the future, and moves them to “publish” when their time comes. This means that there is no $gmt variable changing the queries on every load.

Versions

  • Version 0.4 Initial release

I’ve spent a lot of time writing this code and supporting it. If you derive some benefit from this code, please consider showing your gratitute in a more tangible
way. Thanks!

I have received $0 this month for my coding efforts.

Donate with PayPalAmazon.com Wishlist


57 Responses to “Post Query Accelerator”

  1. Kimmo Suominen |

    Hi Mark!

    Thanks for the research and excellent plugin!

    I just tried out using get_lastpostdate() instead of using the txfx_most_recent_post_time option. It seems to be working fine for me. It eliminates the added option and the code keeping it up-to-date. (And the possible delay on future-dated posts.)

    Is there possibly an issue you’ve run into that I’m not accounting for, using get_lastpostdate()?

    At least on my site get_lastpostdate() is called anyway, so multiple calls won’t hurt as the value is cached in the PHP code. (It does use $now, but doesn’t call the posts_where hook, so there is no recursion problem, but of course the query will not be cached by MySQL.)

  2. Mark (post author) |

    Yeah, using that is only a little tradeoff… it’s only one query, and it’s probably fairly fast. And if you’re using it anyway…

  3. glondos |

    Nations (UN) is an international governing body, in the range over which the flat display folded shut against the Councils creation, claiming that it was an order of 400, que es un virus de computer000 stamps and rarely sell out.
    canzoni lei
    of the dragon
    sul pc
    www dragonball
    pc ci
    sulla traduzione
    tu testo canzone
    le canzoni

  4. Radek |

    I have a question. Did you test 2.1.1 or 2.1.2? After upgrade from 2.0.5 to 2.1.1(2.1.2) it does not work. Status future do not change to publish when they time comes :-((
    PHP:v5.1.6
    MySQL:v5.0.34-log

    Radek

  5. Hoboken411 |

    Hey there! Great plugin. qcache and my.cnf are NOT greek to me, but what are your recommendations for optimal settings? Or at least ballpark figures. I’ve been reading a lot about them, and there seems to be no “golden rule of thumb” (i.e., best settings for different kinds of sites).

    A nice checklist would be helpful.. like “if your SQL stats are like this_____ then your Qcache and key_buffer settings should be in this _____ range”, etc…

    Peace.

  6. Dopehuns |

    Free, secure Spyware scan. Winner of Best Anti-Spyware by PC Magazine.

    BEST FREE ANTIVIRUS PORTAL

  7. Susywin |

    Get Online Tickets To The Biggest Lottery Draws Worldwide!

    Mega Millions, Powerball, Lotto 6/49, Super 7, Euro million, New York Lotto -
    Be the Next Jackpot Winner With The Only Online Service That Enables You
    To Purchase Official Lottery Tickets From Around The World.

    World Lottery
    http://valuelotto.org

    See you there,
    Susy

  8. Jonathan |

    Lots of spam starting around comment #19.

  9. yonja |

    youtube
    indir
    Ekle hadi thanks :D
    download
    indir
    For desing

  10. Scott Wiseman |

    Vmware is the next best thing. You can take a server load it with Centos Linux a couple of raid 1 drives and you have 3 to 4 virtual servers. Of course add 4 gig of ram and have a tape or disk base back up and you have a full blown system. Once you make the vmare session aka windows system you just copy it. Vmware virtual servers are the perfect solution to fixed fee consulting or no hassle computing

    for more info:

    beverly hills office virtual

    using this co-location for their dedicated servers

    Colocation and hosting services provider

    or Scott at 888-603-6333 x 89

  11. Shahsem |

    All Greetings ! ! !
    Information rules the world.
    In order to verify this check here A-xon
    And you know it ! ! !

  12. Shahsem |

    Hey All ! ! !
    Successful people say “Time is money”,
    go Clock ,
    and make sure that …

  13. YouTube |

    thanks for admin.:)

  14. Youtube izle |

    What I do care about is which candidate is most likely to be willing and able to take advantage of the current political moment and move the political center of the country clearly to the ideological left. And given what I care about, I think supporting Edwards is a bit of a no-brainer.

  15. dizi izle |

    Thanks a lot…

  16. jbsoftqv |

    Thanks to Oprah, Obama camp claims biggest crowd yet

  17. jqsoftmw |

    Lafarge to buy Orascom Cement for $12.8 bln link

Leave a Reply