Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 67FAE9FB266 for ; Tue, 31 Oct 2006 18:36:42 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 59282-04 for ; Tue, 31 Oct 2006 18:36:39 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from lists.commandprompt.com (host-130.commandprompt.net [207.173.203.130]) by postgresql.org (Postfix) with ESMTP id ABC299FB259 for ; Tue, 31 Oct 2006 18:36:38 -0400 (AST) Received: from alvh.no-ip.org (201-220-123-102.bk10-dsl.surnet.cl [201.220.123.102]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id k9VMabAR003848; Tue, 31 Oct 2006 14:36:37 -0800 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 9451DC29696; Tue, 31 Oct 2006 19:36:32 -0300 (CLST) Date: Tue, 31 Oct 2006 19:36:32 -0300 From: Alvaro Herrera To: Ivan Voras Cc: pgsql-performance@postgresql.org Subject: Re: MVCC & indexes? Message-ID: <20061031223632.GG12008@alvh.no-ip.org> Mail-Followup-To: Ivan Voras , pgsql-performance@postgresql.org References: <4547C65C.6090208@fer.hr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4547C65C.6090208@fer.hr> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: ClamAV version 0.88.5, clamav-milter version 0.88.5 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Tue, 31 Oct 2006 14:36:38 -0800 (PST) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/636 X-Sequence-Number: 21765 Ivan Voras wrote: > Ok, so MVCC is the best thing since a guy put a round stone on a stick > and called it "the wheel", but I've seen several references on this list > about "indexes not being under MVCC" - at least that's how I read it, > the original posts were explaining why indexes can't be used for solving > MIN()/MAX()/COUNT() aggregates. Is this correct? > > In particular, I'm trying to find out is there (b)locking involved when > concurrently updating and/or inserting records in an indexed table. My > guess is that, since PG does copy+delete on updating, even updating a > non-indexed field will require fixups in the index tree (to point to the > new record) and thus (b)locking. Well, there certainly is locking involved in inserting index entries, but it's more fine-grained than you seem to think. Only one page of the index is locked at any time, resulting in that typically there's very little blocking involved. Two processes can be inserting into the same index concurrently (btree and GiST indexes at least; GiST only gained concurrency in a recent release, I don't remember if it was 8.0 or 8.1). -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.