Search code examples
mysqldatabasecachingquery-cache

Do MySQL supports query caching.? If not is there an alternative in MySQL.?


Do MySQL supports query caching. If not is there any alternative to achieve this.? I found MySQL supports this here.

Is this feature enabled by default.? Or do i need to change any settings.?

Why i am asking is that i am having problems is query with reading huge data from table even if the same query is executed.I will explain the scenario.Consider the following scenarios..

Case 1

Request 1 with input param 'Hello'. Request 2 with input param 'Hello'.

Say for this i have thew following query

select * from table where column = 'Hello'

Request 2 will be executed more faster than request 1.

Case 2

Request 1 with input param 'Hello'. Request 2 with input param 'World'. Request 3 with input param 'Hello'.

Here each requests take same time to complete the execution even if Request 1 & Request 3 are similar. If query caching is there then Request 3 must complete the execution faster than Request 1 since both of them are identical and also the query and results must be in the cache. This is not happening for me. So how to know whether query caching is there.?


Solution

  • Yes, MySQL has query caching. There's a section of the documentation that explains how it works:

    The MySQL Query Cache