Re: how to know if the sql will run a seq scan

2024-10-16 Thread Vijaykumar Jain
> > > > I don't have time now to create an example, but I can point you at: > > > https://www.postgresql.org/docs/current/ddl-partitioning.html#DDL-PARTITIONING-DECLARATIVE > > 5.12.2.2. Partition Maintenance > > "As an alternative to creating a new partition, it is sometimes more > convenient to c

Re: how to know if the sql will run a seq scan

2024-10-16 Thread Adrian Klaver
On 10/16/24 00:02, Vijaykumar Jain wrote: postgres=# create table t(col1 int) partition by list(col1); CREATE TABLE postgres=# create table t1(col1 int) postgres-# ; CREATE TABLE postgres=# insert into t1 select 0 from generate_series(1, 10) x; INSERT 0 10 postgres=# select relname,s

Re: how to know if the sql will run a seq scan

2024-10-16 Thread Vijaykumar Jain
On Wed, 16 Oct 2024 at 02:59, Adrian Klaver wrote: > On 10/15/24 13:50, Vijaykumar Jain wrote: > > Sorry top posting, coz Gmail app on phone. > > > > Yeah, my point was for example we have a large table and we are > > attaching a table as a partition. Now it will scan the whole table to > > valid

Re: how to know if the sql will run a seq scan

2024-10-15 Thread Adrian Klaver
On 10/15/24 13:50, Vijaykumar Jain wrote: Sorry top posting, coz Gmail app on phone. Yeah, my point was for example we have a large table and we are attaching a table as a partition. Now it will scan the whole table to validate the constraint and that will create all sorts of problems. Now y

Re: how to know if the sql will run a seq scan

2024-10-15 Thread Vijaykumar Jain
Sorry top posting, coz Gmail app on phone. Yeah, my point was for example we have a large table and we are attaching a table as a partition. Now it will scan the whole table to validate the constraint and that will create all sorts of problems. I understand the benefit of not valid constraint and

Re: how to know if the sql will run a seq scan

2024-10-15 Thread Adrian Klaver
On 10/15/24 12:50, Vijaykumar Jain wrote: Hi, tl;dr I am trying to learn what sql can result in a full seq scan. Basically there is a lot of info on the internet of what ddl change may take an access exclusive lock while running a seq scan and hold for long.  And for some cases we can make

how to know if the sql will run a seq scan

2024-10-15 Thread Vijaykumar Jain
Hi, tl;dr I am trying to learn what sql can result in a full seq scan. Basically there is a lot of info on the internet of what ddl change may take an access exclusive lock while running a seq scan and hold for long. And for some cases we can make use of "not valid" constraint and then run a val