Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRjrU-0004MM-GZ for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Jun 2018 19:49:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fRjrT-0002Z2-3K for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Jun 2018 19:49:19 +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.89) (envelope-from ) id 1fRjrS-0002Yp-Su; Sat, 09 Jun 2018 19:49:18 +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.89) (envelope-from ) id 1fRjrM-0007Hp-6f; Sat, 09 Jun 2018 19:49:18 +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 w59Jn9MD009662; Sat, 9 Jun 2018 15:49:09 -0400 From: Tom Lane To: Maksim Milyutin cc: pgsql-general@lists.postgresql.org, pgsql-hackers@lists.postgresql.org Subject: Re: Slow planning time for simple query In-reply-to: <36adf760-680b-7a4a-e019-64f4eaaf6ff7@gmail.com> References: <36adf760-680b-7a4a-e019-64f4eaaf6ff7@gmail.com> Comments: In-reply-to Maksim Milyutin message dated "Sat, 09 Jun 2018 21:49:47 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9660.1528573749.1@sss.pgh.pa.us> Date: Sat, 09 Jun 2018 15:49:09 -0400 Message-ID: <9661.1528573749@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Maksim Milyutin writes: > On hot standby I faced with the similar problem. > ... > is planned 4.940 ms on master and *254.741* ms on standby. Presumably the problem is that the standby isn't authorized to change the btree index's "entry is dead" bits, so it's unable to prune index entries previously detected as dead, and thus the logic that intends to improve this situation doesn't work on the standby. (I wonder though why, if you executed the same query on the master, its setting of the index-entry-is-dead bits didn't propagate to the standby.) I wonder if we should extend the "SnapshotNonVacuumable" logic introduced in commit 3ca930fc3 so that in hot standby, *all* index entries are deemed non vacuumable. This would essentially get rid of long standby planning times in this sort of scenario by instead accepting worse (possibly much worse) planner range estimates. I'm unsure if that's a good tradeoff or not. regards, tom lane