pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedconstantly updated table in Amazon RDS
4+ messages / 3 participants
[nested] [flat]
* constantly updated table in Amazon RDS
@ 2022-10-21 18:51 Julie Nishimura <juliezain@hotmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Julie Nishimura @ 2022-10-21 18:51 UTC (permalink / raw)
To: pgsql-general
Hello,
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?
Thanks!
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: constantly updated table in Amazon RDS
@ 2022-10-21 19:08 Michael Nolan <htfoot@gmail.com>
parent: Julie Nishimura <juliezain@hotmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Michael Nolan @ 2022-10-21 19:08 UTC (permalink / raw)
To: Julie Nishimura <juliezain@hotmail.com>; +Cc: pgsql-general
On Fri, Oct 21, 2022 at 1:52 PM Julie Nishimura <juliezain@hotmail.com>
wrote:
> Hello,
> 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?
>
You haven't described the table. Is there some kind of a date or timestamp
field that is included in new records? Otherwise, how do you know when
they were inserted?
A query has a temporarily stable (or consistent) database, inserts, deletes
or updates that occur during the processing of that query (or its
transaction block, if applicable) are ignored. I'm not sure if that
answers your question.
--
Mike Nolan
htfoot@gmail.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: constantly updated table in Amazon RDS
@ 2022-10-22 03:56 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Julie Nishimura <juliezain@hotmail.com>
1 sibling, 1 reply; 4+ messages in thread
From: Laurenz Albe @ 2022-10-22 03:56 UTC (permalink / raw)
To: Julie Nishimura <juliezain@hotmail.com>; pgsql-general
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: constantly updated table in Amazon RDS
@ 2022-10-22 05:32 Julie Nishimura <juliezain@hotmail.com>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 0 replies; 4+ messages in thread
From: Julie Nishimura @ 2022-10-22 05:32 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
Thank you all
________________________________
From: Laurenz Albe <laurenz.albe@cybertec.at>
Sent: Friday, October 21, 2022 8:56 PM
To: Julie Nishimura <juliezain@hotmail.com>; pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: constantly updated table in Amazon RDS
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2022-10-22 05:32 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 18:51 constantly updated table in Amazon RDS Julie Nishimura <juliezain@hotmail.com>
2022-10-21 19:08 ` Michael Nolan <htfoot@gmail.com>
2022-10-22 03:56 ` Laurenz Albe <laurenz.albe@cybertec.at>
2022-10-22 05:32 ` Julie Nishimura <juliezain@hotmail.com>
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