When it’s not possible to remove SQL statements that are unnecessary and the rate of change of common data is relatively low, caching SQL results can provide a significant performance boost to your application and enable additional scalability of your database server.
MySQL Caching
The MySQL query cache can provide a boost in performance for a high read environment and can be implemented without any additional application overhead. The following is an example using the profiling functionality to show the execution time and the individual complexity of a regular SQL statement and a subsequent cached query:
SET GLOBAL query_cache_size=1024*1024*16; SET GLOBAL query_cache_type=1; SET PROFILING=1; SELECT name FROM firms WHERE id=727; SELECT name FROM firms WHERE id=727; SHOW PROFILES;
…
[Read more]