Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1biMEK-0005Me-NW for pgsql-docs@arkaria.postgresql.org; Fri, 09 Sep 2016 13:52:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1biMEK-0007IS-AG for pgsql-docs@arkaria.postgresql.org; Fri, 09 Sep 2016 13:52:32 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1biMEJ-0007FL-Aj for pgsql-docs@postgresql.org; Fri, 09 Sep 2016 13:52:31 +0000 Received: from fr1.2ndquadrant.fr ([2001:41d0:2:127c::1]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1biMEG-00088x-CX for pgsql-docs@postgresql.org; Fri, 09 Sep 2016 13:52:30 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by fr1.2ndquadrant.fr (Postfix) with ESMTP id 8ADF660F7D; Fri, 9 Sep 2016 15:52:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at fr1.2ndquadrant.fr Received: from fr1.2ndquadrant.fr ([127.0.0.1]) by localhost (fr1.2ndquadrant.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w6j1pdGWbASe; Fri, 9 Sep 2016 15:52:24 +0200 (CEST) Received: from [192.168.0.3] (ath91-3-88-167-161-184.fbx.proxad.net [88.167.161.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: charles) by fr1.2ndquadrant.fr (Postfix) with ESMTPSA id 0A60660497; Fri, 9 Sep 2016 15:52:21 +0200 (CEST) Subject: Re: REINDEX and blocking SELECT queries To: Tom Lane , Satoshi Nagayasu References: <19413.1473428496@sss.pgh.pa.us> Cc: pgsql-docs@postgresql.org From: Vik Fearing Message-ID: Date: Fri, 9 Sep 2016 15:52:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <19413.1473428496@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On 09/09/2016 03:41 PM, Tom Lane wrote: > Satoshi Nagayasu writes: >> According to the manual, running REINDEX does not take any locks >> on the parent table which block read operations. >> Actually, REINDEX blocks SELECT queries, maybe in the planning phase. > > Hm. REINDEX does take out only ShareLock on the table, which would not > block DML, but it takes out AccessExclusiveLock on the index. That > blocks the planner's attempts to acquire information about the table's > indexes. > > In the case of an update query I think there's little we can do about > this; the executor would have to update the index anyway. For a pure > SELECT, you could imagine having the planner do a conditional lock acquire > and ignore the index if that fails. Would that be better than blocking? > Not sure. You could end up with a really bad plan if the index was > critical for efficient processing of the query. I agree, things could get awful without certain indexes (I'm thinking of partial indexes in particular). Also, the very next sentence after the one cited says that a SELECT will block if it tries to use the index in question, so I'm not even sure there's anything at all to do here. -- Vik Fearing +33 6 46 75 15 36 http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs