简体   繁体   中英

Postgres + Select query from Cache

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.

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.

只需简单地转到/etc/postgresql/YOUREVERSION/main/posgresql.conf(* nix)(C:\\ Program Files \\ PostgreSQL \\ YOUREVERSION \\ data \\ postgresql.conf(win))找到shared_buffers,取消注释并指定需要的缓存大小。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM