Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fmaT4-0001Y9-HE for pgsql-admin@arkaria.postgresql.org; Mon, 06 Aug 2018 08:02:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fmaT2-0004Xg-Ib for pgsql-admin@arkaria.postgresql.org; Mon, 06 Aug 2018 08:02:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fmaT2-0004XZ-77 for pgsql-admin@lists.postgresql.org; Mon, 06 Aug 2018 08:02:16 +0000 Received: from smtp3-g21.free.fr ([2a01:e0c:1:1599::12]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fmaSy-0002uQ-JM for pgsql-admin@lists.postgresql.org; Mon, 06 Aug 2018 08:02:14 +0000 Received: from firost (unknown [86.199.58.170]) (Authenticated sender: ioguix) by smtp3-g21.free.fr (Postfix) with ESMTPSA id 1125D13F89D; Mon, 6 Aug 2018 10:02:03 +0200 (CEST) Date: Mon, 6 Aug 2018 10:02:01 +0200 From: "Jehan-Guillaume (ioguix) de Rorthais" To: Mariel Cherkassky Cc: Keith , pgsql-admin@lists.postgresql.org Subject: Re: PostgreSQL 11 global index Message-ID: <20180806100201.42a3c794@firost> In-Reply-To: References: X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On Mon, 6 Aug 2018 09:20:45 +0300 Mariel Cherkassky wrote: > The solution you suggested arent helpfull (both unique index and > pg_partman) because I need to make sure that in all the partitions I have a > specific column that is unique. Here is a workaround that actually implement a unique constraint over multi relation. You can avoid first chapters about the problems a UNIQUE constraint deal with. The following link jump directly to the solution: http://blog.ioguix.net/postgresql/2015/02/05/Partitionning-and-constraints-part-1.html#real-solution-adding-locks Regards, > 2018-08-05 23:31 GMT+03:00 Keith : > > > > > > > On Sun, Aug 5, 2018 at 4:58 AM, Mariel Cherkassky < > > mariel.cherkassky@gmail.com> wrote: > > > >> Hi, > >> I read the documentation but i didnt find any word regarding global > >> index. I saw a new feature that indexes that exist on the parent > >> automaticly created on the childs but is there any connection between the > >> indexes ? > >> > >> I'm trying to make sure that 2 different partitions wont have the same > >> data on some of the columns and the partition col isnt one of those column. > >> In oracle that kind of index is called global index. > >> > >> Do you now some third extension maybe that allow you to use such feature > >> ? > >> > >> Thanks , Mariel. > >> > > > > This feature is not yet supported in PostgreSQL. In PG11, you can create a > > unique index, but in order for it to apply to the entire partition set, the > > column must be part of the partition key. I don't believe the native > > partitioning feature even allows you to create an unique index on the > > parent table if the partition key isn't part of it. > > > > I've found some work-arounds for this in pg_partman in the mean time. > > > > https://github.com/pgpartman/pg_partman > > > > To support non-partition key unique columns on native partition sets, I > > have it use a separate template table where you apply your indexes instead > > of the parent table. And while it will enforce the uniqueness per child > > table, it will not enforce it across the entire set. To at least watch for > > this happening, I've provided a python script that goes through all the > > child tables and checks for any duplicates across the whole set. So it > > won't catch it at the time of insertion, but it should at least let you > > know if/when it happens. > > > > Keith > > -- Jehan-Guillaume de Rorthais Dalibo