Re: Partitioned Table Index Column Order

2021-06-23 Thread David Rowley
On Thu, 24 Jun 2021 at 11:56, Tom Lane wrote: > > David Rowley writes: > > On Thu, 24 Jun 2021 at 10:55, Alvaro Herrera > > wrote: > >> It is not relevant from the partitioning point of view. Other factors > >> can be used to decide the column order. > > > I'm not so sure that's really 100% tr

Re: Partitioned Table Index Column Order

2021-06-23 Thread Tom Lane
David Rowley writes: > On Thu, 24 Jun 2021 at 10:55, Alvaro Herrera wrote: >> It is not relevant from the partitioning point of view. Other factors >> can be used to decide the column order. > I'm not so sure that's really 100% true. There is at least one > partitioning feature that will work

Re: Partitioned Table Index Column Order

2021-06-23 Thread David Rowley
On Thu, 24 Jun 2021 at 10:55, Alvaro Herrera wrote: > > On 2021-Jun-23, Rumpi Gravenstein wrote: > > > As a best practice is it better to create the primary key starting or > > ending with the partition column? > > It is not relevant from the partitioning point of view. Other factors > can be use

Re: Partitioned Table Index Column Order

2021-06-23 Thread Tom Lane
Alvaro Herrera writes: > On 2021-Jun-23, Rumpi Gravenstein wrote: >> As a best practice is it better to create the primary key starting or >> ending with the partition column? > It is not relevant from the partitioning point of view. Other factors > can be used to decide the column order. See i

Re: Partitioned Table Index Column Order

2021-06-23 Thread Alvaro Herrera
On 2021-Jun-23, Rumpi Gravenstein wrote: > As a best practice is it better to create the primary key starting or > ending with the partition column? It is not relevant from the partitioning point of view. Other factors can be used to decide the column order. -- Álvaro Herrera Valdivia, C

Partitioned Table Index Column Order

2021-06-23 Thread Rumpi Gravenstein
All, I'm on PostgreSQL 13 and have a partitioned table with a primary key. create table t( a integer, b integer, c varchar, d .. ) partitioned by range( a ); As a best practice is it better to create the primary key starting or ending with the partition column? e.g. 1) t_pkey primary key (a, b