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 1kYYpn-0002tA-T1 for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 18:09:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kYYpm-000814-Mm for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 18:09:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYYpm-00080x-FW for pgsql-admin@lists.postgresql.org; Fri, 30 Oct 2020 18:09:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYYpk-0004C0-As for pgsql-admin@postgresql.org; Fri, 30 Oct 2020 18:09:05 +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 09UI92lM101521; Fri, 30 Oct 2020 14:09:02 -0400 From: Tom Lane To: John Scalia cc: pgsql-admin Subject: Re: Creating a partition table In-reply-to: References: <98825.1604077633@sss.pgh.pa.us> Comments: In-reply-to John Scalia message dated "Fri, 30 Oct 2020 13:48:53 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <101519.1604081342.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 30 Oct 2020 14:09:02 -0400 Message-ID: <101520.1604081342@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk John Scalia writes: > Ok I tried what Laurent had suggested and now the error is: > Insufficient columns in PRIMARY KEY constraint definition. > Now, the attribute the devs want is not a key value in the original tabl= e, but if it were that wouldn=E2=80=99t make a great deal of sense for a p= artition. So, now why did it gripe? FWIW, we recently rephrased that message as "unique constraint on partitioned table must include all partitioning columns", because people were finding it confusing. The reason for the restriction is that a partitioned index is really just a collection of separate indexes on the individual leaf partitions (just as the partitioned table is a collection of plain tables). So it can't enforce uniqueness across partitions unless such uniqueness is guaranteed by the partitioning scheme. Yeah, this is an implementation restriction, but I don't foresee it ever going away. If the indexes weren't independent then you'd lose the scalability benefits that partitioning is meant to provide. regards, tom lane