Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
835 views
in Q2A Core by

I tried setting QA_OPTIMIZE_LOCAL_DB to true (and QA_OPTIMIZE_DISTANT_DB = false) on my production site and realized that the loading time for the HTML part is still the same as before. 

http://docs.question2answer.org/install/optimize/

Could it be that my database and server are not having any advantage by this setting? If so, why?

WITH QA_OPTIMIZE_LOCAL_DB == false

WITH QA_OPTIMIZE_LOCAL_DB == true

You can even see that with the option enabled there are 26 queries, without it is only 21 queries.


PS: I see that the execution time is reduced from 7.0 ms to 5.9 ms indeed, but the requests increased.

Q2A version: 1.7.4

2 Answers

0 votes
by

This question too my interesting. Nice question. After next 1.8 version its actual.

My site home page:

WITH QA_OPTIMIZE_LOCAL_DB == true

WITH QA_OPTIMIZE_LOCAL_DB == false

Question page:

WITH QA_OPTIMIZE_LOCAL_DB == false

0 votes
by

You can even see that with the option enabled there are 26 queries, without it is only 21 queries.

PS: I see that the execution time is reduced from 7.0 ms to 5.9 ms indeed, but the requests increased.

Yes, this is exactly how the option is supposed to work. When optimising for a "distant database" (i.e. a separate database server), Q2A combines many queries into one. This is faster for that setup because there is an additional cost associated with every query made.

When optimising for a "local database" (i.e. when MySQL host setting is "localhost" or "127.0.0.1"), that additional cost does not exist. So running multiple smaller queries is actually faster. The other advantage is that queries are simpler and more easily cached by the MySQL query cache.

So in other words, the "QA_OPTIMIZE_LOCAL_DB" option is not about running fewer queries, it's just about reducing the query time.

However, the main thing I notice in your image is that most of your queries are in the theme section. That means they are almost certainly from plugins or a custom theme. This is outside of Q2A core so the distant database option cannot help with those.

It looks like the queries are not taking much time, so I don't think there is anything to worry about. But it might be worth looking to see if one plugin is making too many queries.

by
> "local database" (i.e. when MySQL host setting is "localhost" or "127.0.0.1")

Actually my database is on "mysql5.mydomain.com" and not set to localhost.

Seems to work... ?!
by
Not sure how your hosting is set up but that may point to the same server, or at least another server very close by. So there is only a small overhead.
...