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 1p00Bz-0007n8-Jk for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2022 12:58:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p00Bx-0001sD-86 for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2022 12:58:29 +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 1p00Bw-0001s4-VC for pgsql-hackers@lists.postgresql.org; Tue, 29 Nov 2022 12:58:28 +0000 Received: from relay10.mail.gandi.net ([217.70.178.230]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p00Bt-0003FY-WB for pgsql-hackers@lists.postgresql.org; Tue, 29 Nov 2022 12:58:27 +0000 Received: (Authenticated sender: vik@postgresfriends.org) by mail.gandi.net (Postfix) with ESMTPSA id B506E24000B; Tue, 29 Nov 2022 12:58:21 +0000 (UTC) Message-ID: Date: Tue, 29 Nov 2022 13:58:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Patch: Global Unique Index Content-Language: en-US To: Cary Huang , Thomas Kellerer Cc: pgsql-hackers References: <184879c5306.12490ea581628934.7312528450011769010@highgo.ca> <3866851668762233@ja6lqgzbqb6tniny.sas.yp-c.yandex.net> <2187643.1668783992@sss.pgh.pa.us> <6cdcb7b1-2567-1373-79d1-96467a9b305b@gmx.net> <184aada3c76.1258dc67d3231678.3658037825540104775@highgo.ca> From: Vik Fearing In-Reply-To: <184aada3c76.1258dc67d3231678.3658037825540104775@highgo.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/24/22 19:15, Cary Huang wrote: > ---- On Thu, 24 Nov 2022 08:00:59 -0700 Thomas Kellerer wrote --- > > Pavel Stehule schrieb am 24.11.2022 um 07:03: > > > There are many Oracle users that find global indexes useful despite > > > their disadvantages. > > > > > > I have seen this mostly when the goal was to get the benefits of > > > partition pruning at runtime which turned the full table scan (=Seq Scan) > > > on huge tables to partition scans on much smaller partitions. > > > Partition wise joins were also helpful for query performance. > > > The substantially slower drop partition performance was accepted in thos cases > > > > > > > > > I think it would be nice to have the option in Postgres as well. > > > > > > I do agree however, that the global index should not be created automatically. > > > > > > Something like CREATE GLOBAL [UNIQUE] INDEX ... would be a lot better > > > > > > > > > Is it necessary to use special marks like GLOBAL if this index will > > > be partitioned, and uniqueness will be ensured by repeated > > > evaluations? > > > > > > Or you think so there should be really forced one relation based > > > index? > > > > > > I can imagine a unique index on partitions without a special mark, > > > that will be partitioned, and a second variant classic index created > > > over a partitioned table, that will be marked as GLOBAL. > > > > > > My personal opinion is, that a global index should never be created > > automatically. > > > > The user should consciously decide on using a feature > > that might have a serious impact on performance in some areas. > > > Agreed, if a unique index is created on non-partition key columns without including the special mark (partition key columns), it may be a mistake from user. (At least I make this mistake all the time). Current PG will give you a warning to include the partition keys, which is good. > > If we were to automatically turn that into a global unique index, user may be using the feature without knowing and experiencing some performance impacts (to account for extra uniqueness check in all partitions). I disagree. A user does not need to know that a table is partitionned, and if the user wants a unique constraint on the table then making them type an extra word to get it is just annoying. -- Vik Fearing