Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjDry-0000Ad-GT for pgsql-admin@arkaria.postgresql.org; Tue, 15 Jan 2019 01:50:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gjDrw-00028b-TW for pgsql-admin@arkaria.postgresql.org; Tue, 15 Jan 2019 01:50:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjDok-0004GY-9W for pgsql-admin@lists.postgresql.org; Tue, 15 Jan 2019 01:47:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjDoh-0006w0-S6 for pgsql-admin@postgresql.org; Tue, 15 Jan 2019 01:47:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x0F1ksK6002614; Mon, 14 Jan 2019 20:46:54 -0500 From: Tom Lane To: "David G. Johnston" cc: "Campbell, Lance" , "pgsql-admin@postgresql.org" Subject: Re: Delete Enhancement Request In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Mon, 14 Jan 2019 18:41:35 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2612.1547516814.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 14 Jan 2019 20:46:54 -0500 Message-ID: <2613.1547516814@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > On Mon, Jan 14, 2019 at 8:18 AM Campbell, Lance wro= te: >> When deleting a large number of records with constraints and triggers P= ostgreSQL is exceptionally slow. > You may wish to provide an explicit situation that you are > experiencing so that others may offer their experienced insights as to > whether you could be doing anything different to increase the speed of > your deletes or techniques to batch them yourself. Given the mention of constraints, I'm suspicious that the problem is foreign key constraint(s) that lack an index on the referencing column(s). PG will let you do that, but if you care about the speed of deletes on the referenced table, you don't want to omit the index on the referencing side. regards, tom lane