pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: clear cache in postgresql
Date: Wed, 16 Jun 2021 13:03:10 +0200
Message-ID: <20210616110310.GB26107@hjp.at> (raw)
In-Reply-To: <20210616063919.hrysiixqgr2wcyrx@nol>
References: <CA+ONtZ75zZv+7ThMdiyFVAa7ZXBSv6NLAGgLqmzbrrjMU3Os8g@mail.gmail.com>
	<20210616063919.hrysiixqgr2wcyrx@nol>

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@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (4+ messages)

Message-ID: <20210616110310.GB26107@hjp.at>
Permalink:  ../20210616110310.GB26107@hjp.at/
Also on:    postgresql.org/message-id/20210616110310.GB26107@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: clear cache in postgresql
  In-Reply-To: <20210616110310.GB26107@hjp.at>
  References: <CA+ONtZ75zZv+7ThMdiyFVAa7ZXBSv6NLAGgLqmzbrrjMU3Os8g@mail.gmail.com> <20210616063919.hrysiixqgr2wcyrx@nol> <20210616110310.GB26107@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox