Re: Partitioned Table Index Column Order

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Rumpi Gravenstein <rgravens(at)gmail(dot)com>, PostgreSQL <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Partitioned Table Index Column Order
Date: 2021-06-23 23:39:16
Message-ID: 2549783.1624491556@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> 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 in particular the hints in

https://www.postgresql.org/docs/current/indexes-multicolumn.html

The only thing that's different about partitioned situations is that
any particular child partition might have only a few values of the
partitioning column, which'd suggest putting it last if there are
no other relevant considerations. However, if you need a particular
column order to match query requirements, that's certainly going
to be a more important consideration.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Rowley 2021-06-23 23:53:29 Re: Partitioned Table Index Column Order
Previous Message Thomas Munro 2021-06-23 23:37:54 Re: Is there something similar like flashback query from Oracle planned for PostgreSQL