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 1olFwA-0001M1-Dx for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 20:45:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1olFw8-00039w-5k for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 20:45:12 +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 1olFw7-00039m-73 for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 20:45:11 +0000 Received: from sonic304-10.consmr.mail.bf2.yahoo.com ([74.6.128.33]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1olFw1-0002IL-P9 for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 20:45:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1666212302; bh=BfbqP8ApYugYzNFC1AmtCaQirzShniU28kwcxqF9Ilc=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject:Reply-To; b=t3xd+qVIY/hXOaS068wdi7U7fravN9DMwtcF/0Mt0l36SP5TN5odCzjtY2sfOkUSt399hgutipaHdxbVx9WedoBGYEs7NvWODrto8YNsNwdTfQr0TKpLZRV5iAgixahXSpw9INiTGLgEV9e/CdWQe+uCdrPEP5KnN84yy9Iv5JhFJJ140Qhb23Hzua5Sr1CwIXXwbuFem1Vqz+aOY2f15a1n0Zv8P+NMdrAp24YsZgV298vqwV5Hd4/CAI0+qjAKMVbHDNgfp+1X+rs/zPpvy6PiopgxUecxYMWTxFvkRxup+hrhFDwZrRx82xO4o15seQnt7HsLyKSfBY6MwM/UAQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1666212302; bh=/vOIPQnhR+omPOqGM+GaOmktSZCxiMvkflwFQ+bTpko=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=bGMKncNU7VOAJCByIfN4RBzCiyeNUGkcFh52t+SZTotA8RAwYnBi54ewJ38606fqLqq3UL4Xn6zw5VXaYdIwZDEmuC/P1oElO/iNbXc50KjziXeMrnTRSr1UseTDuUfu624q+vsz6c2FUPgRF94f6vklo/I0N7WFNPJrXWBUzvOv1CcS9EcPqhI9Vx1cUGrhQiroX7GhDTCw50JPNbd5mTzkTjR/zHJSXxlGG+EoT9fS2po9eqhWO5s2c3EAfGW1b2DKLa/DZZ4wr/pWguuZFQOjQM0Tr5BL89kmqhWC0DLZqFirHqAZRJMEbq2AaYBOcy0D6A9j30tlpL271C+SUQ== X-YMail-OSG: 8_LVRyoVM1lJg.TD6DZyUInkh6yYJVeiaUincOwAaW06uW.t3CrLK1Qjndxc7af dUby_eNBNCcSOtvb1H0elcFWwKoGqSEy0dz_gzKset.lHTdD1UK8yEKRfPbsU1FrQ0EdPzAOOVvP hqpxdhlqso5OnR._1PpJlUQILnCskwNGxi3mtGFivjj4fa9ymQXkxsdZLTT6gP2Ekq5Uqynm.iBN hvUPJfOQ1HX6TQQYHaK1suM7tpxxHgluQjZeY47fZzO4r680kSnh2Sod_kWZEQPaIw3Zo2urk0rL ALgKqM9bLN4L9L8x70XqWnCAwjFygYYT5_lfmnoAuLVOACwTBBRrKesIO_EKH.Bhdxi6E4RAKIw_ lt7WQedOh6pHYDUxDEbIGkEOJbLh9uU6SJe1yR9M1vioohUkxXig6a43_i2t3JeqNeS.RxUlTqd9 H0u9GkmuoY0_injzw5Xaa4aeoWycR7eBZoMnUg4JvK1qx3eHfrZDJHXLv9A3UuKwAcRngovYvlun SPA3vzqHgXU8T0rOmfEU6Q9zKS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xsVMAEQrtV_4g2du70ggQZTjTPonw7chz1K61a vYm8WA9IqwXWYez2kvZGkUYwVKlX060PNTthXud8.AHzSK2wQvWRdPsBn8vkyTeVVLd_VeRt8c3q 1Jd8YDnCYXNr5O8NHu6QaG5VLFzycP3eYhkNyAj0cp8.XXP9QnEmedmwDYqjnRzdJ.ChnN0wujpf QXxUnEOBt_jzAvHULXWdwiqDZWQN0cvjtxo_sogidY6YTHws0j5xOP8HSmjX3QX.OeBc9zVzh1hk n_TAAt3qpQwPM0YuSl0ZyBHkvpFLXvqlXWtz8sxFPNIz6im9xxp2BIdti.OnjJh1yNOrhdaRMeRm hFM.Aqd1HiPth.wB9FQihPQeM2PTGAFYDNYMeK8QembKwRCny9YGC6XOrFKrTPjOHZPjBadOR02e dR5nK3DoWpNnQBciF.no_6ENzEre2kYG.J2B1.l8A9NKa6HCEJlJzgKa8WSpv8qhyI0RJuFpmQOA Dt7KvOsjd_HwvrHGw1Z7U3yMibJij7SNy37ktSuBrupu1x3b1TbjDZkDl24Glrmr5nakhfZw.1WQ zbEP8_fzmzrv605Mh4AvdnvCw1rWSEAPxhuZiy8czJo5AyKzqEHMRmfNQmjbKcQ7_B9nJb1Tdv7m NDmH1xnTZqPwBydPD4BSyvbenkRCbZkaKZ5L5ZZi8R5Zy_aUn.L_qL8_degksmad6.r0ZhN5sWmY yPA1A0BvqZqZY_0hoyJApIne1h87qQ_y6_cZPuakgMuo5IN7m4VEHjvhnVs6uBTK0NYrqcpo- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Wed, 19 Oct 2022 20:45:02 +0000 Date: Wed, 19 Oct 2022 20:44:53 +0000 (UTC) From: Ravi Krishna Reply-To: Ravi Krishna To: ronljohnsonjr@gmail.com, pgsql-general@lists.postgresql.org Message-ID: <726737233.489080.1666212293670@mail.yahoo.com> In-Reply-To: <63222285-dfc6-1937-8e4e-600543f370f8@gmail.com> References: <1365946824.316128.1666186309386.ref@mail.yahoo.com> <1365946824.316128.1666186309386@mail.yahoo.com> <63222285-dfc6-1937-8e4e-600543f370f8@gmail.com> Subject: Re: Speeding up adding fky on a very large table MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_489079_1133661392.1666212293669" X-Mailer: WebService/1.1.20754 aolappandroidmobile Content-Length: 1755 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------=_Part_489079_1133661392.1666212293669 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Our issue is that it takes 20hrs to index the full table. Hopefully we can add FK in multiple child partitions concurrently, otherwise doing it per partition offers no advantage from performance pov. Need to test. Hopefully PG should not lock the referred table during the first build, stopping concurrent execution of other partitions. 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 ------=_Part_489079_1133661392.1666212293669 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
Our issue is that it takes 20hrs to index the full table. Hopefully we can add FK in multiple child partitions concurrently, otherwise doing it per partition offers no advantage from performance pov.

Need to test. Hopefully PG should not lock the referred table during the first build, stopping concurrent execution of other partitions.


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


------=_Part_489079_1133661392.1666212293669--