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 81C1311F6B38 for ; Wed, 26 Apr 2006 23:13:32 -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 40064-07 for ; Wed, 26 Apr 2006 23:13:19 -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 29B5511F6B1C for ; Wed, 26 Apr 2006 23:13:16 -0300 (ADT) Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) by svr4.postgresql.org (Postfix) with ESMTP id 644165B567E for ; Thu, 27 Apr 2006 02:13:17 +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 k3R2DECZ011510 for ; Wed, 26 Apr 2006 21:13:14 -0500 (envelope-from wreese@rackspace.com) Received: from [192.168.10.8] (vpn113-65.sat.rackspace.com [10.1.113.65]) (authenticated bits=0) by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k3R2DDVj000849 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) for ; Wed, 26 Apr 2006 21:13:13 -0500 Mime-Version: 1.0 (Apple Message framework v749.3) In-Reply-To: <445005AD.2000503@ummon.com> References: <9EAB2F2F-0BC2-4685-96A1-A29D7872D068@rackspace.com> <445005AD.2000503@ummon.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1D2B84DA-3FE5-4583-9414-5A7CD9D48E70@rackspace.com> Content-Transfer-Encoding: 7bit From: Will Reese Subject: Re: Slow deletes in 8.1 when FKs are involved Date: Wed, 26 Apr 2006 21:13:18 -0500 To: pgsql-performance@postgresql.org 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/622 X-Sequence-Number: 18706 Stef: There is already a post explaining the solution. All the proper indexes were there, and it works great on 7.4. The problem lies with leftover 7.4 RI triggers being carried over to an 8.1 database. The solution is to drop the triggers and add the constraint. Hopefully this will not cause as many locking issues with FKs on 8.1 as it did in 7.4 (which is why one of the RI triggers was removed in the first place). Will Reese -- http://blog.rezra.com On Apr 26, 2006, at 6:43 PM, Stef T wrote: > > Hey there Will, > I would assume that, perhaps, jst perhaps, the FK doesn't have an > index on the field on both sides, so, your seeing a potential > sequential > scan happening. Can you fling up an explain anaylze for everyone > please > ? Anything more will be merely shooting in the dark, and, tracer > bullets > aside, I have heard that -that- can be dangerous ;p > > Regards > Stef > > Will Reese wrote: >> 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 foreign keys. >> >> I have table A with around 100,000 rows, that has foreign keys to >> around 50 other tables. 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 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 >> >> >> >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 1: if posting/reading through Usenet, please send an appropriate >> subscribe-nomail command to majordomo@postgresql.org so that >> your >> message can get through to the mailing list cleanly >> >