Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwCSq-0002dU-1F for pgsql-general@arkaria.postgresql.org; Wed, 23 Jun 2021 23:39:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lwCSp-0001ql-0i for pgsql-general@arkaria.postgresql.org; Wed, 23 Jun 2021 23:39:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwCSo-0001qc-Nk for pgsql-general@lists.postgresql.org; Wed, 23 Jun 2021 23:39:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwCSm-0005CZ-Bc for pgsql-general@lists.postgresql.org; Wed, 23 Jun 2021 23:39:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15NNdGh62549784; Wed, 23 Jun 2021 19:39:16 -0400 From: Tom Lane To: Alvaro Herrera cc: Rumpi Gravenstein , PostgreSQL Subject: Re: Partitioned Table Index Column Order In-reply-to: <202106232255.3gmtpm5lzc2p@alvherre.pgsql> References: <202106232255.3gmtpm5lzc2p@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 23 Jun 2021 18:55:40 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2549782.1624491556.1@sss.pgh.pa.us> Date: Wed, 23 Jun 2021 19:39:16 -0400 Message-ID: <2549783.1624491556@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 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