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 1olANx-0006s5-4I for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 14:49:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1olANw-0004Lj-0C for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 14:49:32 +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 1olANv-0004La-Mh for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 14:49:31 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1olANt-0006yV-Jq for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 14:49:30 +0000 Received: by mail-ot1-x335.google.com with SMTP id 101-20020a9d0bee000000b00661b54d945fso9625014oth.13 for ; Wed, 19 Oct 2022 07:49:29 -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:subject:date:message-id :reply-to; bh=M8FFJL14NPQcLgrFYN14VgBu/G4WupVVXOnDBmoWBV0=; b=ZtL0SMu4fUUFhyeo+dSIoSHt4+VT5kybT5fLp86BLDUy+LVnUbFis1dj4Hq0CjBVqM IwmR+qVnX6441dHR4L73WiM/9b3orb7OrMOPmEbRXV7YBQsT1rlH/h9qqgeRCwqLwVEd PigPVJEcj2iqXdLksgT9ORzbmLkP2Oiag7Rg6h4CzI7xdB8Jg5j05x+GpVdwwd+W4fPG plBFpJs+E2hewAjZnJCdNFmSkIgPm6QAOHKU+FCycEs1TEnUWSL4UlMHeeySO+gd6j+t dMjAxeilZOANBwcMi+yTrF70tr5/bfnT/kX4B6jnW+F41YWNvjbUtItKcN/tfuZJwXNU CJtg== 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:subject :date:message-id:reply-to; bh=M8FFJL14NPQcLgrFYN14VgBu/G4WupVVXOnDBmoWBV0=; b=WSAFxmOhdoOf/jiAMKB70YUCoR/2R2LYFiRHuxSgCt8WPr+G4fw9v3Zn2zjZ+EhC8r VOB/MFhYJg+VG2MI618ypkUiM06gMxOKkFRafcT+57TrU3e6aUvPPe5QMkLnxwaO38vO 9qPT9Za92nb5ktL1yMpqCdShee5CwzaCtV1pZwPKeX7xDBVJtxwSnvuufZtYzHKntoqr rS+HBzQi9B+5mgsQlszu0wip9lh6rY/ocs/T/KuD1HLhrLbuNa2xF81UK7FqOLPVUGXb 3Jult7wbMLU7TaT2TlAMN4O+lEglrRXSeWicnglUO/B8/7X1F8YCgVyDB/DDjMJd7R5a ONBA== X-Gm-Message-State: ACrzQf0e84UbtsDUZAl1IfQt6EL/E5z18M2GOy0QES9/mgOJiA+gZDcC Stc0kL5U1ZHo0hOjAw35yWqUh31MIjY= X-Google-Smtp-Source: AMsMyM4xWrpLmPJhLKKNy9lMNQo8+U6xKnp6GsyVWFfxY73W5l9aqySCVNvsaJF4rOkbJvQWUu6+ig== X-Received: by 2002:a05:6830:6203:b0:65c:39a9:4007 with SMTP id cd3-20020a056830620300b0065c39a94007mr4143194otb.92.1666190968013; Wed, 19 Oct 2022 07:49:28 -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 z36-20020a056870d6a400b0012b298699dbsm7795255oap.1.2022.10.19.07.49.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Oct 2022 07:49:27 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------1qCuOnvizauRaq32YUzGSUjx" Message-ID: <63222285-dfc6-1937-8e4e-600543f370f8@gmail.com> Date: Wed, 19 Oct 2022 09:49:26 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Speeding up adding fky on a very large table Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <1365946824.316128.1666186309386.ref@mail.yahoo.com> <1365946824.316128.1666186309386@mail.yahoo.com> From: Ron In-Reply-To: <1365946824.316128.1666186309386@mail.yahoo.com> 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. --------------1qCuOnvizauRaq32YUzGSUjx Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/19/22 08:31, Ravi Krishna wrote: > AWS Aurora based on PG 13. > > > Large partitioned table of 5+ billion rows and 7TB in size. > > ALTER TABLE abc ADD CONSTRAINT fk_123 FOREIGN KEY (a,b,c) REFERENCES > xyz(1,2,3); > > It seems this is not parallelized. Is there a way. Or directly going into > each partition is the only way ( not even sure it is possible). In vanilla Postgresql (including RDS Postgresql) you can add the FK to each partition and then ALTER TABLE ONLY the parent table. Don't know about Aurora, though. -- Angular momentum makes the world go 'round. --------------1qCuOnvizauRaq32YUzGSUjx Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/19/22 08:31, Ravi Krishna wrote:
AWS Aurora based on PG 13.


Large partitioned table of 5+ billion rows and 7TB in size.

ALTER TABLE abc ADD CONSTRAINT fk_123 FOREIGN KEY (a,b,c) REFERENCES xyz(1,2,3);

It seems this is not parallelized. Is there a way. Or directly going into each partition is the only way ( not even sure it is possible).

In vanilla Postgresql (including RDS Postgresql) you can add the FK to each partition and then ALTER TABLE ONLY the parent table.

Don't know about Aurora, though.

--
Angular momentum makes the world go 'round.
--------------1qCuOnvizauRaq32YUzGSUjx--