X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 584A9D1B527 for ; Fri, 12 Sep 2003 13:33:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83446-01 for ; Fri, 12 Sep 2003 10:32:55 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 3E844D1B529 for ; Fri, 12 Sep 2003 10:32:51 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 19xo2h-0005ex-00 for ; Fri, 12 Sep 2003 09:32:55 -0400 Received: by dba2 (Postfix, from userid 1019) id 8CDC7C583; Fri, 12 Sep 2003 09:32:55 -0400 (EDT) Date: Fri, 12 Sep 2003 09:32:55 -0400 From: Andrew Sullivan To: pgsql-admin@postgresql.org Subject: Re: Row locking during UPDATE Message-ID: <20030912133255.GC26074@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-admin@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/206 X-Sequence-Number: 10294 I didn't see any response to this. Sorry if this is already stale for you. On Thu, Sep 04, 2003 at 08:21:17AM -0400, David F. Skoll wrote: > Questions: > > 1) Am I on the right track? Is this how PostgreSQL works? More or less, yes. The significant part here is that the postmaster won't notice that the client is gone until it returns from the work it was trying to do. It'll eventually come back, but it'll take some time. How low does your contention need to be? > A statistics update looks like this: > > UPDATE low_contention_stats SET value = value + 1 > WHERE date = current_date AND key = 'KEY' > AND randomizer = my_random_val AND not summarized; > (If the update updates 0 rows, we do an INSERT) > > The summary process when we copy to statistics looks like this: If you're going to summarise anyway, why not just always insert into a "holding" table, and then periodically (infrequently, though) select out of there and summarise at that point. Note that if you do this very frequently, and you have also to select the summary data, it won't work (as I have learned from painful experience) because the holding table will gradually build up a lot of dead tuples. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110