X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 95D075337D for ; Fri, 13 May 2005 13:42:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73457-09 for ; Fri, 13 May 2005 16:42:46 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4F89853AB5 for ; Fri, 13 May 2005 13:42:46 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4DGgilO024734; Fri, 13 May 2005 12:42:44 -0400 (EDT) To: "Mindaugas Riauba" Cc: "Cosimo Streppone" , pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load In-reply-to: <02f901c557d2$43517e10$f20214ac@bite.lt> References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <4284C661.4050406@streppone.it> <02f901c557d2$43517e10$f20214ac@bite.lt> Comments: In-reply-to "Mindaugas Riauba" message dated "Fri, 13 May 2005 18:41:43 +0300" Date: Fri, 13 May 2005 12:42:44 -0400 Message-ID: <24733.1116002564@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/266 X-Sequence-Number: 12430 "Mindaugas Riauba" writes: > Hm. Yes. Number of locks varies quite alot (10-600). Now what to > investigate > further? We do not use explicit locks in our functions. We use quite simple > update/delete where key=something; > Some sample (select * from pg_locks order by pid) is below. The sample doesn't show any lock issues (there are no processes waiting for ungranted locks). The thing that typically burns people is foreign key conflicts. In current releases, if you have a foreign key reference then an insert in the referencing table takes an exclusive row lock on the referenced (master) row --- which means that two inserts using the same foreign key value block each other. You can alleviate the issue by making all your foreign key checks deferred, but that just shortens the period of time the lock is held. There will be a real solution in PG 8.1, which has sharable row locks. regards, tom lane