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 473765284D for ; Mon, 11 Jul 2005 11:51:27 -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 66453-10 for ; Mon, 11 Jul 2005 14:51:24 +0000 (GMT) Received: from cmailg4.svr.pol.co.uk (cmailg4.svr.pol.co.uk [195.92.195.174]) by svr1.postgresql.org (Postfix) with ESMTP id F1C2852824 for ; Mon, 11 Jul 2005 11:51:23 -0300 (ADT) Received: from modem-1688.lion.dialup.pol.co.uk ([217.135.166.152] helo=192.168.0.102) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.41) id 1Drzd0-0002CH-S4; Mon, 11 Jul 2005 15:51:27 +0100 Subject: Re: cost-based vacuum From: Simon Riggs To: Ian Westmacott Cc: pgsql-performance@postgresql.org In-Reply-To: <1121087266.27427.35.camel@spectre.intellivid.com> References: <1120839902.20657.197.camel@spectre.intellivid.com> <1121081504.3970.53.camel@localhost.localdomain> <1121087266.27427.35.camel@spectre.intellivid.com> Content-Type: text/plain Organization: 2nd Quadrant Date: Mon, 11 Jul 2005 15:51:28 +0100 Message-Id: <1121093488.3970.70.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.053 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/109 X-Sequence-Number: 13350 On Mon, 2005-07-11 at 09:07 -0400, Ian Westmacott wrote: > On Mon, 2005-07-11 at 07:31, Simon Riggs wrote: > > The ANALYZE commands hold read locks on the tables you wish to write to. > > If you slow them down, you merely slow down your write transactions > > also, and then the read transactions that wait behind them. Every time > > the ANALYZE sleeps it wakes up the other transactions, which then > > realise they can't move because of locks and then wake up the ANALYZEs > > for another shot. The end result is that you introduce more context- > > switching, without any chance of doing more useful work while the > > ANALYZEs sleep. > > Let me make sure I understand. ANALYZE acquires a read > lock on the table, that it holds until the operation is > complete (including any sleeps). That read lock blocks > the extension of that table via COPY. Is that right? > > According to the 8.0 docs, ANALYZE acquires an ACCESS SHARE > lock on the table, and that conflicts only with ACCESS > EXCLUSIVE. Thats why I didn't think I had a lock issue, > since I think COPY only needs ROW EXCLUSIVE. Or perhaps > the transaction needs something more? The docs are correct, but don't show catalog and buffer locks. ...but on further reading of the code there are no catalog locks or buffer locks held across the sleep points. So, my explanation doesn't work as an explanation for the sleep/no sleep difference you have observed. Best Regards, Simon Riggs