Support » Themes and Templates » Query Call

  • Can someone tell me exactly what that “num_queries” call is contained in the “WordPress” credit paragraph at the bottom of the index.php page please?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Mark (podz)


    Support Maven

    It’s how long the program took to query the database to build the page.
    I think 🙂

    No. That’s the “time” call. This one returns the number of queries and I’m wondering exactly what’s meant by queries.




    The number of database queries executed to fetch information from the database.

    Oh right. Thanks skippy. Just wondering if it was something I could use elsewhere.

    is there a good or recommended number of queries per page to shoot for? i’m sure too many too often would probably be hard on the server, but how much is that?
    i ask because i added prev/next post links before and after posts on single post pages like on Photo Matt’s and many others’ sites. (i grabbed the code from Matt’s index.php page in the wiki, and it uses the previous_post and next_post tags.) i noticed that added 4 more queries for each set, for a total of 8 more, going from 19 to 27 on post pages. is that “safe” – nothing to worry about? and my template is still pretty basic at this point, there’ll probably be more features and functions in the future.

    I had mine up to 70 and was going for 100, but unfortunately it fell to 60. I’ll have to snag a few more “useless” hacks/plugins, I guess 😉

    Depends on your website performance. Every hosting provider has things set up slightly differently. Mine has a different server running the MySQL instance than the apache/php box — so each query has to go out over the internal network to get processed. At home, everything is on one machine, so it goes through a null-pipe to talk to the SQL service.
    My belief is that around two dozen is pretty good if you are running a few useful plugins. Beel is going to be my ‘test optimization’ case over time, to see if I can help him come down a bit more (though I >was< part of the problem at one point!). Caching is key, as is not doing queries you don’t really have to, and requesting all the data you can rather than a secondary query later.
    Of course, there’s the inevitable tradeoff of asking for too much data, which takes longer to process and send back on the wire, versus asking for minimal data and thus needing a second/followup query to fill in the blanks.
    At the end of the day, if your page loads fast enough for you, and your hosting provider isn’t bitching about you taking a hit on their SQL server, you’re okay with a few dozen certainly, more in certain circumstances (i.e., I have administrative scripts which run hundreds of queries on a given page…).

    thanks for the info, davidchaitt. i’m not too worried about it, especially since my site has essentially no traffic, but it’s good to know. i’ve also been eying the Staticize caching plugin, which would help lighten the load – if there were a load to lighten.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Query Call’ is closed to new replies.