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 F2CB811F61EE for ; Wed, 26 Apr 2006 20:44:09 -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 06578-01 for ; Wed, 26 Apr 2006 20:43:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtpout08-04.prod.mesa1.secureserver.net (smtpout08-04.prod.mesa1.secureserver.net [64.202.165.12]) by postgresql.org (Postfix) with SMTP id D730011F61E8 for ; Wed, 26 Apr 2006 20:43:53 -0300 (ADT) Received: (qmail 25566 invoked from network); 26 Apr 2006 23:43:53 -0000 Received: from unknown (69.199.39.70) by smtpout08-04.prod.mesa1.secureserver.net (64.202.165.12) with ESMTP; 26 Apr 2006 23:43:52 -0000 Message-ID: <445005AD.2000503@ummon.com> Date: Wed, 26 Apr 2006 19:43:41 -0400 From: Stef T User-Agent: Mail/News 1.5 (X11/20060309) MIME-Version: 1.0 To: Will Reese CC: pgsql-performance@postgresql.org Subject: Re: Slow deletes in 8.1 when FKs are involved References: <9EAB2F2F-0BC2-4685-96A1-A29D7872D068@rackspace.com> In-Reply-To: <9EAB2F2F-0BC2-4685-96A1-A29D7872D068@rackspace.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/619 X-Sequence-Number: 18703 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 >