4

I have a rather database intensive application for a server which is intended to be turned off and on throughout the day. The issue comes at first use of the application after startup; it is slower than intended due to the large volumes of queries.

Once the query cache has taken ahold it is much more efficient and user experience pleasing. Obviously for the user experience I would like this throughout and not after the queries have been cached.

Is it reasonable, in terms of performance and error handling, to run a cron script (php) on startup to execute some queries so they can be cached or is there a method to save the mysql cache and load on the service startup?

0

1 Answer 1

2

please refer to this link? this should answer your question

Yes, 100% reasonable to make use of the MySQL caching system!

How to "warm up" a cold DB server?

Warm-up is needed because the best performance of a database is achieved when its various caches are populated with the most relevant data, since reading from memory is generally substantially faster than reading from disk.

InnoDB has the InnoDB buffer pool. MyISAM has the key cache and the OS cache. Then there's also the MySQL query cache. MySQL has the open table cache. Some or all of these structures contribute to the ideal performance of a server. When a server is handling traffic that is characteristic of its workload, it tends to have the most frequently used -- and therefore presumably the most relevant data -- already cached.

Take the load off of an active MySQL server and you will not see it start closing tables and evicting data from its caches. If you leave it running, then come back to it tomorrow, you should find that it's still as warm as you left it.

2
  • Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.
    – davejal
    Jan 18, 2016 at 19:27
  • @davejal no problem I shall do that in a bit!
    – TheHidden
    Jan 19, 2016 at 9:26

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.