X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6BA9311F6B55 for ; Mon, 24 Apr 2006 02:41:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 80482-07-2 for ; Mon, 24 Apr 2006 02:39:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C7E8811F8D07 for ; Mon, 24 Apr 2006 00:32:40 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3O3WdUE020019; Sun, 23 Apr 2006 23:32:39 -0400 (EDT) To: Will Reese cc: pgsql-performance@postgresql.org Subject: Re: Slow deletes in 8.1 when FKs are involved In-reply-to: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> References: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> Comments: In-reply-to Will Reese message dated "Sun, 23 Apr 2006 21:41:14 -0500" Date: Sun, 23 Apr 2006 23:32:39 -0400 Message-ID: <20018.1145849559@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/520 X-Sequence-Number: 18604 Will Reese writes: > ... Both servers have identical postgresql.conf settings and were > restored from the same 7.4 backup. Almost everything is faster on the > 8.1 server (mostly due to hardware), except one thing...deletes from > tables with many foreign keys pointing to them. I think it's unquestionable that you have a bad FK plan in use on the 8.1 server. Double check that you have suitable indexes on the referencing (not referenced) columns, that you've ANALYZEd all the tables involved, and that you've started a fresh psql session (remember the backend tends to cache FK plans for the life of the connection). It might help to EXPLAIN ANALYZE one of the slow deletes --- 8.1 will break out the time spent in FK triggers, which would let you see which one(s) are the culprit. regards, tom lane