Take the 2-minute tour ×

Does any of the DBMS (Oracle, MySQL, SQLite, PostGres) provide caching of the result set? I am trying to understand what is the most common method to cache the SQL results so that database load can be reduced. My understanding is that the database is a bottleneck for scaling the application, and caching would help reduce the load in database.

If the DBMS does not provide caching of the results, is it a good idea to use a cache tools such as Memcache?

share|improve this question
Can't speak for the others, and this is just slightly-biased opinion but the MySQL query cache has always failed me in the past. Something like memcached will serve you much better in the long run. –  Corbin Jul 17 '12 at 5:07
add comment

2 Answers

up vote 3 down vote accepted

Databases usually cache the execution plan of the query, not the result set itself.

One feasible approach is certainly do what you suggest and use Memcache for this. Memcache is just one of many tools out there that provide this sort of capability. The decision largely depends on the environment you are working on, type of application (web vs windows), architecture, etc.

If the result set is not too big, you could potentially cache it in memory, for example.

share|improve this answer
I don't know about mysql ,but you can do that in oracle see the link provide link –  Gaurav Soni Jul 17 '12 at 20:11
@GauravSoni MySQL also supports the same thing - or kind of, there are many limitations - dev.mysql.com/doc/refman/5.1/en/query-cache.html But if the idea is to reduce the load on the database server, I think putting cached data on a different place makes more sense. Caching the data on the database side still requires some processing on the DB although admittedly lower... –  Icarus Jul 17 '12 at 20:35
@lcarus:Thanks for your response ,i got it what you want to convey :) –  Gaurav Soni Jul 17 '12 at 20:40
add comment

Oracle offers several ways to achieve a cache. It depends on which version of the Oracle database you are using. In older versions you could opt to "pin a table in memory". This effectively cached any frequently accessed table into cache. Care needs to be taken here in that this could be used a little too liberally. There is also the option of using Materialized Views. Now, this is not a method of caching but the benefits along the same lines as caching. Oracle 11g now allows the caching of queries at both database and session level. This is achieved through the use of hints. Look for RESULT_CACHE_MODE and RESULT_CACHE. There are various configuration settings and EXPLAIN PLAN can display whether a query is being read from RESULT CACHE. I don't have experience of third party tools such as Memcache(?) but the danger of using tools such as this - is you may actually circumvent anything (something of benefit) Oracle implements into their own RDBMS.

share|improve this answer
add comment

Your Answer


