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


59 Responses to “Post Query Accelerator”

  1. 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 says:

    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. [...] Un autre plug-in très utile, (fonctionne sur Wordpress 2.01), à télécharger sur Post query accelerator qui augmente la vitesse de mise à jour de manière impressionnante en gérant le cache serveur. Blogosphere, plugin, template, wordpress [...]

  4. [...] Another useful plug-in, (functions on Wordpress 1.5 and +), download from Post query Accelerator impressively increases update speed by managing the server cache. Blogosphere, plugin, template, wordpress [...]

  5. [...] Opcode cache helps quite a bit. I use APC. I wrote this plugin to make WP’s posts queries change less, so that you can use MySQL’s Qcache, which helps some more. WP-Cache2 is great (but be sure to read this first if you’re using APC), and I’d recommend changing the cache time to 7200 seconds (default is 3600). [...]

  6. 一篇关于优化 WP 服务器性能的文章。APC å’Œ MySQL Query Cache 应该说是比较通用的 LAMP 平台优化加速的方法了。而文中提到了两个 WP 专用的脚本 object-cache å’Œpost-query accelerator 则值得我们写自己的应用时借鉴一番。 Targeting Content 女人,看球光荣!评球可耻!–IamTing

  7. [...] Post Query Accelerator: Sets $now to the time of the latest post, instead of the current time, which allows for MySQL caching of such queries.  Read more here about optimising WordPress Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. [...]

  8. [...] Despite getting a significant speed increase from installing APC and also turning on MySQL’s query cache, I still wasn’t satisfied and I wanted more speed. The next optimisation step I found again came from Mark Jacquith in the form of the Post-Query Accelerator, which ensures that WordPress gets the most out of MySQL’s Query Cache. Here’s how it works in Mark’s own words: 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. [...]

  9. glondos says:

    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

  10. [...] khususnya berhubungan dengan query post Wordpress. Sudah ada pluginnya, bisa didownload dari http://txfx.net/code/wordpress/post-query-accelerator/ Instalasi juga sangat mudah karena tinggal upload ke /wp-content/plugins dan klik activate di menu [...]

  11. [...] more thing is needed to make this all come together: Mark Jaquith’s Post Query Accelerator. As Mark points out on his blog, WordPress “always ask[s] for posts with post_date_gmt <= [...]

  12. Radek says:

    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

  13. Shirley says:

    Hmm… sweet!

  14. Hoboken411 says:

    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.

  15. [...] nation! hi sweetheart! I found an interesting plugin that might help with server load. http://txfx.net/code/wordpress/post-query-accelerator/ __________________ 37 PR3 hardlink trades - AR TGP Network | HQ Teen Softcore Trades contact [...]

  16. Dopehuns says:

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

    BEST FREE ANTIVIRUS PORTAL

  17. Susywin says:

    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

  18. [...] おわかりのとおり、「今より前」なので、SQL を発行するたびに条件が変わってしまうからです。 Post Query Accelerator [...]

  19. Jonathan says:

    Lots of spam starting around comment #19.

  20. yonja says:

    youtube
    indir
    Ekle hadi thanks :D
    download
    indir
    For desing

  21. Scott Wiseman says:

    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

  22. Shahsem says:

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

  23. Shahsem says:

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

  24. 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. For those of you who want more information on this…head here. For those of your that find this is greek to you, stay away. So there you have it people. 7 tips and tricks that the average joe can put together without any high flying need for coding this and that. Digg proof your site. Actually, for those of you

  25. YouTube says:

    thanks for admin.:)

  26. [...] suspend my site, they offered suggestions. Upon hearing I had WP-SuperCache running, they found PostQueryAccelerator and suggested I try that, and they would handle the server config changes to make it work. [...]

  27. Youtube izle says:

    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.

  28. ceza says:

    thanks girls :)

  29. dizi izle says:

    Thanks a lot…

  30. youtube says:

    thanks. hello

  31. Letsdown.net says:

    Thanks for the post.

  32. [...] khususnya berhubungan dengan query post Wordpress. Sudah ada pluginnya, bisa didownload dari http://txfx.net/code/wordpress/post-query-accelerator/ Instalasi juga sangat mudah karena tinggal upload ke /wp-content/plugins dan klik activate di menu [...]

  33. jbsoftqv says:

    Thanks to Oprah, Obama camp claims biggest crowd yet

  34. jqsoftmw says:

    Lafarge to buy Orascom Cement for $12.8 bln link

  35. [...] khususnya berhubungan dengan query post Wordpress. Sudah ada pluginnya, bisa didownload dari http://txfx.net/code/wordpress/post-query-accelerator/ Instalasi juga sangat mudah karena tinggal upload ke /wp-content/plugins dan klik activate di menu [...]

  36. [...] khususnya berhubungan dengan query post WordPress. Sudah ada pluginnya, bisa didownload dari http://txfx.net/code/wordpress/post-query-accelerator/ Instalasi juga sangat mudah karena tinggal upload ke /wp-content/plugins dan klik activate di menu [...]

  37. [...] khususnya berhubungan dengan query post Wordpress. Sudah ada pluginnya, bisa didownload dari http://txfx.net/code/wordpress/post-query-accelerator/ Instalasi juga sangat mudah karena tinggal upload ke /wp-content/plugins dan klik activate di menu [...]

  38. ForumKD says:

    very very thanx…

Leave a Reply