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 1oRaco-0001R9-U3 for pgsql-general@arkaria.postgresql.org; Fri, 26 Aug 2022 14:47:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oRacn-0000yH-Rn for pgsql-general@arkaria.postgresql.org; Fri, 26 Aug 2022 14:47:57 +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 1oRacn-0000vn-D6 for pgsql-general@lists.postgresql.org; Fri, 26 Aug 2022 14:47:57 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oRacl-0003mj-5q for pgsql-general@lists.postgresql.org; Fri, 26 Aug 2022 14:47:57 +0000 Received: by mail-ot1-x32e.google.com with SMTP id 6-20020a9d0106000000b0063963134d04so1151891otu.3 for ; Fri, 26 Aug 2022 07:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc; bh=DmD1yAuThqZSuc/WvRtH/b0lwMHjYg7kRJhLpjAbbRY=; b=lDmzjwdu7b1vMGSUyAmgrp27foCpXgLsGBPpVkTkqJR42tRWm3e3HBFKkUdEgfBqWd wGqnh3GMOHCrB7ECin7ZLYGjZ+9gwfQgVWcvIjo//MJSbT7Iae2N1mBuR0JGrPQUfDE6 Rh+LOXkMgy9rrgr1mo6ad1YXHXRewpPboucYvShwJ5XpvfNYDwqVd9t16lKDdtgoFwa6 Jtzde5NMH8SGW5JZygn3vrqPfOUAvb9ftsahANVmmAZ0z6B0eYmKWi3aDW0RzNS5WT2O z6lItlVd7nlYSncwVBnSNAq1F8bGvY8HjNwXQCD4GwNhIgbYRTAeVJPGJyh+OhIkwDWW nLjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc; bh=DmD1yAuThqZSuc/WvRtH/b0lwMHjYg7kRJhLpjAbbRY=; b=kvNu7V/yJpCIAhz+qKeTS7OlKybrnYPQ31R6fFxFQ2HF/dyIxdXMZ+VRBUE73CPkaA UT5XTmA/IATY6y47HbjlncuegqM61iGI6AI2puXEIkNcSUvmipPhLgbkoNTxazQCe0ux 9e9pw4IVsGEQDB0R2nSjg+pgCXBUefiaYNB6R/tqO5R94sL8MlhBrZqy9FjgRcN6itol WgAcaLY2rE1fl2SR2O1mG3N2Cnu+CPxMPPGtYXAZxf+jDH/f/uHSXFGUPALogpYvgiv9 n0n5LwSkg3o9HGdwvBXaU2krT6/a2Kb/YuIQoYCJscdqNhUTsd3VUlftEf2XAuKOth81 uqxw== X-Gm-Message-State: ACgBeo1H/iNKgxWJDj2N28EYU4/TGdTfdNePWNsQqyC4d/X2nB5FGsTm lhtbH2VJ8wDwiy9LTuqBb5oh6ARlhSo= X-Google-Smtp-Source: AA6agR6xQcPvo4kBtND2sp4Wa04G7RFaScpKzzx2s1mfTnL+R1G01oTIl3Yu5qrMBXdyhSdt+LRi+A== X-Received: by 2002:a9d:618a:0:b0:639:1921:374f with SMTP id g10-20020a9d618a000000b006391921374fmr1532964otk.174.1661525273236; Fri, 26 Aug 2022 07:47:53 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id p6-20020a9d76c6000000b0063922bfde24sm1130093otl.28.2022.08.26.07.47.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Aug 2022 07:47:52 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------Sqetuv8L1d0QsFSxW5w2dnw6" Message-ID: <57c67972-6655-9f7d-b4af-29b5ce108a1c@gmail.com> Date: Fri, 26 Aug 2022 09:47:52 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Restriction on table partition expressions Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------Sqetuv8L1d0QsFSxW5w2dnw6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit It certainly does make sense to have global indices on partitioned tables.  Rdd/VMS had them 20+ years ago, and they are (I still have two production systems using Rdb on OpenVMS) darned useful. Did it require dropping the index before dropping a partition? Absolutely!!  But *of course* /every//RDBMS has limitations/.  You accept and work around them, or migrate to a different RDBMS. On 8/26/22 03:50, James Vanns wrote: > Thanks for that, David. It makes sense and no, it certainly wouldn't > do to have a global index across all the partitions! It sounds like > the key thing that needs highlighting is if the result of an > expression (function call in this case) cannot guarantee the > uniqueness of the value across all partitions, then that is why it's > forbidden. > > Cheers > > Jim > > On Thu, 25 Aug 2022 at 16:32, David Rowley wrote: >> On Fri, 26 Aug 2022 at 03:08, James Vanns wrote: >>> Also, is there a chance that this >>> limitation will be relaxed in the future? >> (forgot to answer this part) >> >> Certainly not in the near future, I'm afraid. It would require >> allowing a single index to exist over multiple tables. There has been >> discussions about this in the past and the general thoughts are that >> if you have a single index over all partitions, then it massively >> detracts from the advantages of partitioning. With partitioning, you >> can DETACH or DROP a partition and get rid of all the data quickly in >> a single metadata operation. If you have an index over all partitions >> then that operation is no longer a metadata-only operation. It >> suddenly needs to go and remove or invalidate all records pointing to >> the partition you want to detach/drop. >> >> David > > -- Angular momentum makes the world go 'round. --------------Sqetuv8L1d0QsFSxW5w2dnw6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit It certainly does make sense to have global indices on partitioned tables.  Rdd/VMS had them 20+ years ago, and they are (I still have two production systems using Rdb on OpenVMS) darned useful.

Did it require dropping the index before dropping a partition?  Absolutely!!  But of course every RDBMS has limitations.  You accept and work around them, or migrate to a different RDBMS.

On 8/26/22 03:50, James Vanns wrote:
Thanks for that, David. It makes sense and no, it certainly wouldn't
do to have a global index across all the partitions! It sounds like
the key thing that needs highlighting is if the result of an
expression (function call in this case) cannot guarantee the
uniqueness of the value across all partitions, then that is why it's
forbidden.

Cheers

Jim

On Thu, 25 Aug 2022 at 16:32, David Rowley <dgrowleyml@gmail.com> wrote:
On Fri, 26 Aug 2022 at 03:08, James Vanns <jvanns@ilm.com> wrote:
Also, is there a chance that this
limitation will be relaxed in the future?
(forgot to answer this part)

Certainly not in the near future, I'm afraid.  It would require
allowing a single index to exist over multiple tables. There has been
discussions about this in the past and the general thoughts are that
if you have a single index over all partitions, then it massively
detracts from the advantages of partitioning.  With partitioning, you
can DETACH or DROP a partition and get rid of all the data quickly in
a single metadata operation.  If you have an index over all partitions
then that operation is no longer a metadata-only operation. It
suddenly needs to go and remove or invalidate all records pointing to
the partition you want to detach/drop.

David



--
Angular momentum makes the world go 'round.
--------------Sqetuv8L1d0QsFSxW5w2dnw6--