Skip site navigation (1) Skip section navigation (2)

Re: Postgres Cache usage

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: A J <s5aly(at)yahoo(dot)com>
Cc: PG Admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Postgres Cache usage
Date: 2012-09-20 02:28:36
Message-ID: 505A7F54.2090204@ringerc.id.au (view raw or flat)
Thread:
Lists: pgsql-admin
On 09/20/2012 12:36 AM, A J wrote:
> Hi,
> I have a read heavy application. I would want it to read from memory as
> database latency has to be in low milliseconds.
> The database is not too big in size and can be fully contained in memory.
>
> With Postgres, if I cache all the tables (by pre-emptive querying such
> as select * from tables); is it assured that all subsequent queries that
> have involved where clauses made up of several indexed fields will still
> hit the cache (unless data is refreshed by writes) ?
>
> Example if my first query is select * from table1. Then if my second
> query is "select * from table1 where (field1 between v1 and v2) and
> (field2 between v3 and v4)"; would the second query read from the cache ?

The second query will most likely get cached tuples from the heap, but 
the index(es) won't be in RAM so it won't have cached copies of them to use.

What you want to do is "pre-warm" the caches. Search for "postgresql 
prewarm". See, eg:

http://archives.postgresql.org/message-id/CA+TgmobRrRxCO+t6gcQrw_dJw+Uf9ZEdwf9beJnu+RB5TEBjEw@mail.gmail.com

--
Craig Ringer



In response to

pgsql-admin by date

Next:From: Haifeng LiuDate: 2012-09-20 08:55:46
Subject: how to allow integer overflow for calculating hash code of a string?
Previous:From: David MortonDate: 2012-09-20 02:13:08
Subject: WAL File Volume

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group