From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Julie Nishimura <juliezain@hotmail.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: constantly updated table in Amazon RDS
Date: Sat, 22 Oct 2022 05:56:20 +0200
Message-ID: <19ee98cd64c022b906d11e690bbff012ef71baff.camel@cybertec.at> (raw)
In-Reply-To: <BL3PR05MB91864E59784551EC7451EA14AC2D9@BL3PR05MB9186.namprd05.prod.outlook.com>
References: <BL3PR05MB91864E59784551EC7451EA14AC2D9@BL3PR05MB9186.namprd05.prod.outlook.com>
On Fri, 2022-10-21 at 18:51 +0000, Julie Nishimura wrote:
> A table is constantly updated by inserting new rows. Will it affect select if where clause is based on > date?
> Does "where clause" to specify > date and < now?
Potentially yes, if the rows you query are the most recent rows, for which PostgreSQL
has the least accurate statistics. There is a heuristics in the PostgreSQL optimizer:
it looks for the actual maximal value to adjust the last histogram bucket boundary.
If that is not enough, you can get PostgreSQL to gather table statistics more often
by lowering "autovacuum_analyze_scale_factor" for that table:
ALTER TABLE tab SET (autovacuum_analyze_scale_factor = 0.01);
You'd have to experiment for the best value.
Yours,
Laurenz Albe
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: laurenz.albe@cybertec.at, juliezain@hotmail.com
Subject: Re: constantly updated table in Amazon RDS
In-Reply-To: <19ee98cd64c022b906d11e690bbff012ef71baff.camel@cybertec.at>
References: <BL3PR05MB91864E59784551EC7451EA14AC2D9@BL3PR05MB9186.namprd05.prod.outlook.com> <19ee98cd64c022b906d11e690bbff012ef71baff.camel@cybertec.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