Re: Slow planning time for simple query

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Maksim Milyutin <milyutinma(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Slow planning time for simple query
Date: 2018-06-17 15:52:56
Message-ID: 87lgbdquul.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 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)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2018-06-17 17:31:51 Re: Trying to understand odd trigger behavior
Previous Message Tom Lane 2018-06-17 14:46:08 Re: Slow planning time for simple query

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2018-06-17 17:23:19 Re: Microoptimization of Bitmapset usage in postgres_fdw
Previous Message Tom Lane 2018-06-17 14:57:16 Re: pg_config.h.win32 missing a set of flags from pg_config.h.in added in v11 development