Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltTKH-0008GV-C2 for pgsql-general@arkaria.postgresql.org; Wed, 16 Jun 2021 11:03:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ltTKF-0001wS-Bt for pgsql-general@arkaria.postgresql.org; Wed, 16 Jun 2021 11:03:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltTKF-0001wK-36 for pgsql-general@lists.postgresql.org; Wed, 16 Jun 2021 11:03:15 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltTKB-0007TB-Kl for pgsql-general@lists.postgresql.org; Wed, 16 Jun 2021 11:03:14 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id A61FF4E46; Wed, 16 Jun 2021 13:03:10 +0200 (CEST) Date: Wed, 16 Jun 2021 13:03:10 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: clear cache in postgresql Message-ID: <20210616110310.GB26107@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <20210616063919.hrysiixqgr2wcyrx@nol> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="z6Eq5LdranGa6ru8" Content-Disposition: inline In-Reply-To: <20210616063919.hrysiixqgr2wcyrx@nol> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --z6Eq5LdranGa6ru8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --z6Eq5LdranGa6ru8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmDJ2mkACgkQ8g5IURL+ KF0fkBAAmZ1RizwgDpPtg8+tfxwibBRi1ObSTbTcAG0Mq68cYEKAPC0059J6V88l vykb0tqQtT1jTlir3laIgQ9pclojRgJ0q+GqBGbxewvn9VhD9YfeUxNfIt65ddjN JAKB5LjQWZsB9/vSzcVKj6TP+SqoZS79FabvIAi9V3iUFziZDGDmZT5ejVsvZAHn G4cZoiiPYdYoaaqX+WDHCACaUdX3ca1yR39viSREPPPmoJiJd6kxUkN2Zy99Pxu3 0Rq0H5x7/QTJscRMAeVlF73qV1loFUhWkCDQYJNkJK/h2NBHNm9IAM/ZeKamQOVI 8ybpMeuP2ZWTRc+SR14YWSCbTnyO9p7JRulD8GPIc7aF43v2zAX8iXXLMn5kmWy7 CvGJde4ySrFXUx8nuvd84J1COw9PrBJlV294nSNNIiwDOytQho4O++tUIXfOzyhP B8GURqU/QtpjBh9dVEqkTKggKZCoVW36nRLctQ86Ba41zNdOuyshaJRh0OwXLqzR ra0peTa6KPeyzbHa3P4Inu1g/9G/Bx/Lr1vNCab0N4EGZya9YvW+XPKv1K0d4MBw 2uPTNhJ8k5owLWoMxGGv9i+zZvGQw7wZdJBKmyd8YN1f5q6QPWaQ8DMU4z8jwbRV DgW7DOPQ/TjxbqqWaybQ05Cqu1Kmh6Aj9mI1B0RfDZsUE9e+26E= =JWc7 -----END PGP SIGNATURE----- --z6Eq5LdranGa6ru8--