pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Rumpi Gravenstein <rgravens@gmail.com>
Cc: PostgreSQL <pgsql-general@lists.postgresql.org>
Subject: Re: Partitioned Table Index Column Order
Date: Wed, 23 Jun 2021 19:39:16 -0400
Message-ID: <2549783.1624491556@sss.pgh.pa.us> (raw)
In-Reply-To: <202106232255.3gmtpm5lzc2p@alvherre.pgsql>
References: <202106232255.3gmtpm5lzc2p@alvherre.pgsql>

Alvaro Herrera <alvherre@alvh.no-ip.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





view thread (6+ messages)  latest in thread

Message-ID: <2549783.1624491556@sss.pgh.pa.us>
Permalink:  ../2549783.1624491556@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2549783.1624491556@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alvherre@alvh.no-ip.org, rgravens@gmail.com
  Subject: Re: Partitioned Table Index Column Order
  In-Reply-To: <2549783.1624491556@sss.pgh.pa.us>
  References: <202106232255.3gmtpm5lzc2p@alvherre.pgsql> <2549783.1624491556@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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