Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ADFCE476043 for ; Mon, 20 Jan 2003 11:59:57 -0500 (EST) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id D1D9F475E75 for ; Mon, 20 Jan 2003 11:59:56 -0500 (EST) Received: from ron [206.112.112.139] by torque.intervideoinc.com with ESMTP (SMTPD32-5.05) id AEC35930114; Mon, 20 Jan 2003 09:15:47 -0800 Date: Mon, 20 Jan 2003 09:58:10 -0800 (PST) From: Ron Mayer X-X-Sender: To: Tom Lane Cc: Bhuvan A , Subject: Re: deadlock problem in Ad serving.. In-Reply-To: <3021.1043075890@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/208 X-Sequence-Number: 7050 On Mon, 20 Jan 2003, Tom Lane wrote: > > Bhuvan A writes: > >> Error:...deadlock detected... > > ... You can overcome this by locking the table in share row > > exclusive mode also... > > ...use shorter transactions (one per page, not one per several pages). Hmm... with his query: "update banner_stats set imp=imp+1 where uniqid=4330" Is it true that the problem happens when updates are done in a different order by two transactions like this: trans.1: "update banner_stats set imp=imp+1 where uniqid=4330" trans.2: "update banner_stats set imp=imp+1 where uniqid=10" trans.1: "update banner_stats set imp=imp+1 where uniqid=10" trans.2: "update banner_stats set imp=imp+1 where uniqid=4330" If so, then could the problem be avoided if in his application logic he always did the updates in the same order? ... I.e. Make sure the each transaction does the updates in the same order by sorting his updates based on uniqid in the client? Ron