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 EF36411F6E80 for ; Sun, 23 Apr 2006 23:49:08 -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 55007-01 for ; Sun, 23 Apr 2006 23:41:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 2C7AE11F61C9 for ; Sun, 23 Apr 2006 23:41:03 -0300 (ADT) Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) by svr4.postgresql.org (Postfix) with ESMTP id 75DF35AF8E9 for ; Mon, 24 Apr 2006 02:41:05 +0000 (GMT) Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k3O2f2D0031950 for ; Sun, 23 Apr 2006 21:41:03 -0500 (envelope-from wreese@rackspace.com) Received: from [192.168.10.8] (vpn113-66.sat.rackspace.com [10.1.113.66]) (authenticated bits=0) by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k3O2f1m1002168 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) for ; Sun, 23 Apr 2006 21:41:02 -0500 Mime-Version: 1.0 (Apple Message framework v749.3) Content-Transfer-Encoding: 7bit Message-Id: <22780344-3C6A-474E-8101-60B8806DA152@rackspace.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: pgsql-performance@postgresql.org From: Will Reese Subject: Slow deletes in 8.1 when FKs are involved Date: Sun, 23 Apr 2006 21:41:14 -0500 X-Mailer: Apple Mail (2.749.3) X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0' X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/518 X-Sequence-Number: 18602 I'm preparing for an upgrade from PostgreSQL 7.4.5 to 8.1.3, and I noticed a potential performance issue. I have two servers, a dual proc Dell with raid 5 running PostgreSQL 7.4, and a quad proc Dell with a storage array running PostgreSQL 8.1. 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 have table A with around 100,000 rows, that has foreign keys from about 50 other tables pointing to it. Some of these other tables (table B, for example) have around 10 million rows. On the 7.4 server, I can delete a single row from a table A in well under a second (as expected). On the 8.1 server, it takes over a minute to delete. I tried all the usual stuff, recreating indexes, vacuum analyzing, explain analyze. Everything is identical between the systems. If I hit ctrl-c while the slow delete was running on 8.1, I repeatedly got the following message... db=# delete from "A" where "ID" in ('6'); Cancel request sent ERROR: canceling statement due to user request CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."B" x WHERE "A_ID" = $1 FOR SHARE OF x" It looks to me like the "SELECT ... FOR SHARE" functionality in 8.1 is the culprit. Has anyone else run into this issue? Will Reese -- http://blog.rezra.com