Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1biM3p-0004uw-SN for pgsql-docs@arkaria.postgresql.org; Fri, 09 Sep 2016 13:41:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1biM3p-00064f-EU for pgsql-docs@arkaria.postgresql.org; Fri, 09 Sep 2016 13:41:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1biM3p-00064Z-6D for pgsql-docs@postgresql.org; Fri, 09 Sep 2016 13:41:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1biM3m-0004F5-DF for pgsql-docs@postgresql.org; Fri, 09 Sep 2016 13:41:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u89Dfat9019414; Fri, 9 Sep 2016 09:41:36 -0400 From: Tom Lane To: Satoshi Nagayasu cc: pgsql-docs@postgresql.org Subject: Re: REINDEX and blocking SELECT queries In-reply-to: References: Comments: In-reply-to Satoshi Nagayasu message dated "Fri, 09 Sep 2016 20:48:23 +0900" Date: Fri, 09 Sep 2016 09:41:36 -0400 Message-ID: <19413.1473428496@sss.pgh.pa.us> 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 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. regards, tom lane -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs