1

I'm looking at optimising a rather large site I've been adding to and adding to. The database has become pretty big (maybe 100,000 posts) and it has started slowing down somewhat and giving me "Mysql has gone away"errors. I've been reading about database optimisation and have ready some people saying you should only be looking to use 1-15 queries on a page.

Do people think the suggestion that only a handful of queries should be used on any page?

Am I correct in thinking that every time I use a Wordpress function such as get_permalink() I am creating a new query and new connection the database?

I have some loops in there that literally loop through 100+ users at a time and use functions such as get_user_meta() in these loops - so would this mean I am literally making 100 database queries or are they somehow cached in Wordpress?

Thanks

2 Answers 2

0

Looking a the source code of get_permalink(), that function not always generates additional queries. It depends on the particular situation. get_user_meta() is always performing aditional queries although they can be stored in wp cahe.

Take a look into Save queries for analysis and this helpful plugin. You will be able to see the total number of queries, time taking by each one and other useful information that will help you to know if using a especific function is generating aditional queries or not.

-1

Use Redis for caching. Google is fetching my posts on 50-60 ms. before redis google was fetching on 700-800 ms.

http://www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/

3
  • Using cache system can make a website loads faster but it has nothing to do with the optimization. If you are running 100 queries in 5 seconds and the same results can be archived with only 5 queries in 0.05 seconds, use the second option independently of using a cache system.
    – cybmeta
    Sep 5, 2013 at 15:46
  • but loading faster effects search engine optimization.
    – ahmetlutfu
    Sep 6, 2013 at 8:27
  • No doubt bro, but it is not the scope of the question.
    – cybmeta
    Sep 6, 2013 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.