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 1l4K1C-0006Ox-3p for pgsql-admin@arkaria.postgresql.org; Tue, 26 Jan 2021 08:48:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l4K1B-0000LO-1P for pgsql-admin@arkaria.postgresql.org; Tue, 26 Jan 2021 08:48:09 +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 1l4K1A-0000LH-OS for pgsql-admin@lists.postgresql.org; Tue, 26 Jan 2021 08:48:08 +0000 Received: from mout.gmx.net ([212.227.15.18]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l4K18-0003n1-1K for pgsql-admin@lists.postgresql.org; Tue, 26 Jan 2021 08:48:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1611650883; bh=ywQOrkg4bqRf68dVMxlVwuH0wh6hErqZjYUMfRKK7Vg=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=bNFUAKrtc2nzLiGrc8eAPA+nG7K3bUyuyAlvUF91Qdjnm1OD8/+dmdRiRBAl9k2g+ fMUrFwhg/rZ7lyOJLXs8ugElBSDR/ir6RzOfbfa2kKa4kfx12ruPPlLemAUsL08G64 KbMQOReWEUivWozs1KKBbKAdpjq81GD7I9Gml1FQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.1.33.240] ([185.40.248.10]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mof5H-1lo8Es0W9B-00p8Ts for ; Tue, 26 Jan 2021 09:48:03 +0100 Subject: Re: Unique constraint across all partitions? To: pgsql-admin@lists.postgresql.org References: <3d00c1f4-646c-59b7-e4dc-1d51190d2139@gmail.com> <5ebaba7ee42d89f8bfb2599de203612024c86e8e.camel@cybertec.at> From: Thomas Kellerer Message-ID: <6a847296-d02f-6582-3dcb-e3e60dbc56b6@gmx.net> Date: Tue, 26 Jan 2021 09:48:01 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: <5ebaba7ee42d89f8bfb2599de203612024c86e8e.camel@cybertec.at> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:P0eFwYw+w+09pRUOVvFYt4lxfg7XijXdv3Cre4CYhOZkiY3Y2t+ CnNQIuP/iKxzXgxCjt/AjXmM+74PdBKVZ74vdYTXa1PCwdwdu2GHZGEQ+4w77j3pJKMzaXg hywviwHK1zNzrBmXt677NUV+y/r9bl4SgfWRk9OnYpCfRVx3mcEclkMtjv45jgzgbtZqECK RlRph0JxhR2ytBUkJdqHQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:WJio7mVtM+E=:zj8ThXBInHh3K5VlTdiO5j CshMkOlvoyEi8JmRMXpJQl/bpKJvUiDS1QiWpyU/Uhwj/atQMoWplOYGDVKLgXUrM6ooFKfYy ftG4iBP8HL+/mXFwDS6RoHeI/3KPce2iOrg/RcE90BFLdom4TYN4cXyH/TE3O4DF2HAd/bkEA EcV3n/3KmJJ5UikU+lmg7oepktHktmlrEC3tsMgfXyiR3Ju5mih9lnnXSJhdhNF+1OsbPEYiQ dlhun++iHjJ9KV6PZjv4PUdWbec48BFfIK12TAG2sQuGOj8yG1DKuBsLxbt+Pak9kCOi4SuVy sUG2D6nb4+5MwEvmbpollbMu6kFIoxYF5RRx/H1Vl+asehCCXrBp3IRuFfN6whWg3YzAwkUju p/J244nr9pEeLq2C4NLAgEN32df1FcnMue2xln/uON09qnyoi0flFQ6Pw3mLd6nE7gHo3MH3c 7WCDSN+sJZ7ikfxMbDtCx2n1hq8mlQfT+g9AVbbm4WZqVnkvi74+9hX6atOMrdwnWILRVSv6o 4yihSVLkuniCdFbp113/SxDL9eZ8fYeW/DaqpXFqNixVBcN/+CVoPY/ItXbxKQ11eKjlfoGRF WbL16b1hlJ9y7yrAz1OurqFXKx/SWH7juj0czYkq58v6+Bmc0BXf53nktHVMTxV/zQ6NBq47m FuNS1F4Xu/Mdk2ryX9uz//RGcKqSDiwG+3nccO57xdy97qDvQFg8+gveQ7DpejsgQ3oftj4Kj OWXCRHbCBuOsTYcr3Tn2nRVn2rviO7SWB5a1/QJvDvjE6jA4bPV3jiT3SkZYmqXbqD9O6pOOH 7LQu2uBqVoW+ldr6q17w60HfX5tXgeDQvdfViyKE4aHe9ALw5r5Bb4m2HBQMObOTjAmkVv7wN hYY16oJ+A72Fgt2LnrnA== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Laurenz Albe schrieb am 26.01.2021 um 09:33: >>> So, yes, so long as your unique constraint takes into >>> consideration the partitioning scheme it will enforce uniqueness >>> across all of the partitions. But the answer to the full, but >>> possibly >>> implied, question is no. >> >> This is why global indices are needed. > > Global indexes are likely more pain than gain. While not extremely popular, many Oracle users do find them useful. > They will make the best part of partitioning (attaching and detaching > partitions) painfully slow. Hardly worth it to gain a tiny little bit > of integrity. Within a partition, you can guarantee uniqueness easily. I wonder why they would make the "best parts" slow? I would expect that partition pruning or partition wise joins are unaffect= ed by that (which I do consider one of the "best parts") Obviously the overhead of maintaining the index is there, especially when dropping partitions this would mean a substantial overhead. But it's up to the user to decide if the benefits (proper foreign keys, un= iqueness) outweigh the disadvantages. Is there any other downside I am missing? Would DML statements be affected (if you factor out the cost of maintainin= g the global index)? Thomas