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 1222853238 for ; Mon, 16 May 2005 07:05:15 -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 65066-01 for ; Mon, 16 May 2005 10:05:06 +0000 (GMT) Received: from ns1.bi.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 9419452A62 for ; Mon, 16 May 2005 07:05:03 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bi.lt (8.12.11/8.12.11) with SMTP id j4GA54qY027498; Mon, 16 May 2005 13:05:04 +0300 Message-ID: <025401c559fe$bb852e80$f20214ac@bite.lt> From: "Mindaugas Riauba" To: "Tom Lane" Cc: "Cosimo Streppone" , 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> <24733.1116002564@sss.pgh.pa.us> Subject: Re: PostgreSQL strugling during high load Date: Mon, 16 May 2005 13:05:04 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.181 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/301 X-Sequence-Number: 12465 > > 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. In such case our foreign key contraint should not be an issue since it is on msg_id which is pretty much unique among concurrent transactions. And I noticed that "storms" happens along with higher write activity. If bo in vmstat shows 25+MB in 2s then most likely I will get "storm" of slow queries in serverlog. How to even write activity? fsync=off, bgwriter settings are default. And is it possible to log which query in function takes the longest time to complete? Also do not know if it matters but PG database is on ext3 partition with data=journal option. Thanks, Mindaugas