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 1lQAA3-0000dH-In for pgsql-admin@arkaria.postgresql.org; Sat, 27 Mar 2021 14:43:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lQAA2-00025R-HU for pgsql-admin@arkaria.postgresql.org; Sat, 27 Mar 2021 14:43:34 +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 1lQAA2-00025J-AK for pgsql-admin@lists.postgresql.org; Sat, 27 Mar 2021 14:43:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQA9v-0007vv-5X for pgsql-admin@lists.postgresql.org; Sat, 27 Mar 2021 14:43:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 12REhLW42002504; Sat, 27 Mar 2021 10:43:22 -0400 From: Tom Lane To: Laurenz Albe cc: Jacque Edmund , pgsql-admin@lists.postgresql.org Subject: Re: Native Foreign Keys housekeeping time intensive for Relational Model In-reply-to: References: Comments: In-reply-to Laurenz Albe message dated "Sat, 27 Mar 2021 11:24:30 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2002502.1616856201.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 27 Mar 2021 10:43:21 -0400 Message-ID: <2002503.1616856201@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Laurenz Albe writes: > On Fri, 2021-03-26 at 14:00 -0400, Jacque Edmund wrote: >> I've already seen that my current set of FK relationships between < 100= tables and data footprint >> has yielded very large lookup times for the underlying referential inte= grity of the FKs to vet >> whether it can DELETE a row or not based on its FK relationships. > I would be surprised if correctly indexed foreign keys would slow delete= s down so that > the performance becomes intolerable. Deletes being slow often means that you don't have an index on the referencing column(s). PG requires you to have an index on the referenced columns, but not on the other side of the FK relationship. regards, tom lane