Re: clear cache in postgresql

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: clear cache in postgresql
Date: 2021-06-16 11:03:10
Message-ID: 20210616110310.GB26107@hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2021-06-16 14:39:19 +0800, Julien Rouhaud wrote:
> On Wed, Jun 16, 2021 at 12:02:52PM +0530, Atul Kumar wrote:
> > Sometimes I run a Postgres query it takes 30 seconds. Then, I
> > immediately run the same query and it takes 2 seconds.
[...]
> > Can I force all caches to be cleared for tuning purposes?
> > So I need to clear the cache without restarting/rebooting the postgres
> > server to check the correct execution plan of my query.
>
> No, cleaning postgres cache can only be done with a service restart. That
> being said, tuning shouldn't be done assuming that there's no cache.

I agree mostly, but not entirely. The most important case to optimize is
of course the normal case, where at least some of the data will already
be cached. Hoewever, I do think it is also important to ensure that the
rare cases are still acceptable. If a given operation takes 2 seconds
95 % of the time but 30 seconds 5 % of the time that makes for a poor
user experience, expecially if its seemingly at random (because it
depends on what other users have done recently). So you may want to
investigate those cases, too.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marcin Barczynski 2021-06-16 14:01:18 Establishing a local connection to PostgreSQL 9.6 takes seconds
Previous Message David Rowley 2021-06-16 10:41:49 Re: query issue