I was wondering if Postgres had a feature like SQL_CACHE in mySQL. For example in mySQL I can do a query like "SELECT SQL_CACHE Product_ID, Product_Name, Product_Sku FROM Products" I want to know if I can do something similar in Postgres.
3 Answers
PostgreSQL automatically caches recently accessed data in memory, depending on your shared_buffers configuration parameter. There's really no need for an SQL_CACHE feature, since Postgres already does a great job of managing the tuple cache.
3 Comments
Frank Heikens
Wrong parameter, the only cache PostgreSQL has, is shared_buffers.
Kenaniah
@Frank. That's what I get for typing too quickly. Thanks :-)
In MySQL, SQL_CACHE doesn not select from cache, depending on query_cache_type, this happens:
- 1 or ON: Cache all cacheable query results except for those that begin with
SELECT SQL_NO_CACHE. - 2 or DEMAND: Cache results only for cacheable queries that begin with
SELECT SQL_CACHE.
In essence, using SQL_NO_CACHE with any setting other the 1 or SQL_CACHE with any other setting the 2 is meaningless.
If this is still what you need in PostgreSQL: no idea, but I had to make this very clear.