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 1fUZzH-0003Uf-5q for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Jun 2018 15:53:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fUZzE-0008Ko-4g for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Jun 2018 15:53:04 +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.89) (envelope-from ) id 1fUZzD-0008Ke-QV for pgsql-hackers@lists.postgresql.org; Sun, 17 Jun 2018 15:53:03 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fUZzA-0002Cc-D3 for pgsql-hackers@lists.postgresql.org; Sun, 17 Jun 2018 15:53:02 +0000 Received: from [192.168.127.1] (port=35122 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1fUZz8-0003MT-0B; Sun, 17 Jun 2018 15:52:58 +0000 Received: from [127.0.0.1] (port=15567 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1fUZz7-0001TZ-7w; Sun, 17 Jun 2018 15:52:57 +0000 From: Andrew Gierth To: Tom Lane Cc: Amit Kapila , Maksim Milyutin , PostgreSQL Hackers Subject: Re: Slow planning time for simple query In-Reply-To: <7067.1529246768@sss.pgh.pa.us> (Tom Lane's message of "Sun, 17 Jun 2018 10:46:08 -0400") Message-ID: <87lgbdquul.fsf@news-spur.riddles.org.uk> References: <36adf760-680b-7a4a-e019-64f4eaaf6ff7@gmail.com> <9661.1528573749@sss.pgh.pa.us> <87po0pr97m.fsf@news-spur.riddles.org.uk> <7067.1529246768@sss.pgh.pa.us> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Sun, 17 Jun 2018 16:52:56 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Tom" == Tom Lane writes: Tom> * During recovery we ignore killed tuples and don't bother to kill them Tom> * either. We do this because the xmin on the primary node could easily be Tom> * later than the xmin on the standby node, so that what the primary Tom> * thinks is killed is supposed to be visible on standby. So for correct Tom> * MVCC for queries during recovery we must ignore these hints and check Tom> * all tuples. Do *not* set ignore_killed_tuples to true when running in a Tom> * transaction that was started during recovery. xactStartedInRecovery Tom> * should not be altered by index AMs. Tom> but it seems to me that this is not terribly carefully thought through. Tom> 1. If global xmin on the primary is later than on the standby, Tom> VACUUM could remove tuples that should be visible on the standby, Tom> and that would shortly propagate to the standby. Simply ignoring Tom> index kill bits on the standby won't prevent that. Right, but we have conflict detection for vacuum's tuple removal actions, which we don't have for the index hints. Tom> 2. Although _bt_killitems doesn't WAL-log its setting of kill Tom> bits, those bits could propagate to the standby anyway, as a Tom> result of a subsequent WAL action on the index page that gets a Tom> full-page image added. That's OK as long as we're ignoring those hints on the standby. Tom> I believe that in some replication modes, #1 isn't a problem Tom> because we have mechanisms to hold back the primary's global xmin. That's the case if feedback is enabled, but not if it's disabled, which is sometimes done intentionally to ensure that long-running queries on the standby don't hold back the master's xmin horizon. Conflict detection then comes into play to kill the aforesaid long-running queries before vacuuming away anything they might see. -- Andrew (irc:RhodiumToad)