Re: Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread Laurenz Albe
On Thu, 2025-12-18 at 13:48 -0500, Matthew Planchard wrote: > In a table with high insert frequency (~1.5k rows/s) and high query > frequency (~1k queries/s), partitioned by record creation time, we have > observed the following behavior: > > * When the current time crosses a partition boundary, a

Re: PQexecPrepared() question

2025-12-18 Thread Laurenz Albe
On Thu, 2025-12-18 at 07:20 -0800, Igor Korot wrote: > Imagine following scenario: > > I have 2 machines. One is running PG server on *nix. Second is my app on > Windows. > > An application starts for the first time. > > What is “clientencoding in this case? If I read the code correctly: - if

Re: Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread Ron Johnson
On Thu, Dec 18, 2025 at 3:21 PM David Rowley wrote: > On Fri, 19 Dec 2025 at 08:55, Matthew Planchard > wrote: > > > How about just force seqscan off when the table is created? > > > ALTER TABLE SET (enable_seqscan = off); > > > > I didn't know this could be set on the table level! Our partiti

Re: Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread David Rowley
On Fri, 19 Dec 2025 at 08:55, Matthew Planchard wrote: > > How about just force seqscan off when the table is created? > > ALTER TABLE SET (enable_seqscan = off); > > I didn't know this could be set on the table level! Our partitions are > created by partman, but we have a nightly job that does

Re: Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread David Rowley
On Fri, 19 Dec 2025 at 07:48, Matthew Planchard wrote: > * Because the planner's latest knowledge of the partition was based on > its state prior to the cutover, it assumes the partition is empty and > creates plans that use sequential scans If the table/partition was just created and not ana

Re: Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread Matthew Planchard
Thanks very much for the reply and the suggestions, a lot of good stuff to look at. > What's autovacuum_analyze_scale_factor set to? The default 20% is pretty > high. > autovacuum_naptime might need to be dropped, too. This is just whatever the default is, so I will look into updating these se

Re: Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread Ron Johnson
On Thu, Dec 18, 2025 at 1:48 PM Matthew Planchard wrote: > > In a table with high insert frequency (~1.5k rows/s) and high query > frequency (~1k queries/s), partitioned by record creation time, we have > observed the following behavior: > > * When the current time crosses a partition boundary, a

Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread Matthew Planchard
In a table with high insert frequency (~1.5k rows/s) and high query frequency (~1k queries/s), partitioned by record creation time, we have observed the following behavior: * When the current time crosses a partition boundary, all new records are written to the new partition, which was previou

Dealing with SeqScans when Time-based Partitions Cut Over

2025-12-18 Thread Matthew Planchard
In a table with high insert frequency (~1.5k rows/s) and high query frequency (~1k queries/s), partitioned by record creation time, we have observed the following behavior: * When the current time crosses a partition boundary, all new records are written to the new partition, which was previou

Re: PQexecPrepared() question

2025-12-18 Thread Igor Korot
Hi, David, On Thu, Dec 18, 2025 at 7:41 AM David G. Johnston wrote: > > On Thu, Dec 18, 2025 at 8:20 AM Igor Korot wrote: >> >> Imagine following scenario: >> >> I have 2 machines. One is running PG server on *nix. Second is my app on >> Windows. >> >> An application starts for the first time.

Re: PQexecPrepared() question

2025-12-18 Thread David G. Johnston
On Thu, Dec 18, 2025 at 8:20 AM Igor Korot wrote: > Imagine following scenario: > > I have 2 machines. One is running PG server on *nix. Second is my app on > Windows. > > An application starts for the first time. > > What is “clientencoding in this case? > This day in age, probably UTF-8; which

Re: PQexecPrepared() question

2025-12-18 Thread Igor Korot
Hi, On Tue, Dec 16, 2025 at 11:32 PM Laurenz Albe wrote: > On Tue, 2025-12-16 at 21:53 -0800, Igor Korot wrote: > > Is there some default value for client_encoding? > > The default value for a client connection is whatever the parameter > "client_encoding" was set to in the PostgreSQL server con

Re: Record last SELECT on a row?

2025-12-18 Thread Kris Deugau
Matthias Leisi wrote: If the application's behavior is simple and well-defined, this might be good enough, of course. FWIW when I read the original email in the thread I got the impression that the application behavior was pretty simple WRT this table. But of course I could easily be wrong