2

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.

0

3 Answers 3

4

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
  • 3
    That's not entirely correct. effective_cache_size does not influence the cache that Postgre manages. It only give the planner a hint how like it will be that data is already in the filesystem cache. The bigger that value, the less expensive random seeks are treated.
    – user330315
    Commented Apr 5, 2011 at 20:33
  • 1
    Wrong parameter, the only cache PostgreSQL has, is shared_buffers. Commented Apr 6, 2011 at 5:45
  • @Frank. That's what I get for typing too quickly. Thanks :-)
    – Kenaniah
    Commented Apr 6, 2011 at 19:32
0

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.

0

just simple goto /etc/postgresql/YOUREVERSION/main/posgresql.conf (*nix) ( C:\Program Files\PostgreSQL\YOUREVERSION\data\postgresql.conf (win)) find shared_buffers, uncomment itб and specify need cache size.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.