Re: Slow planning time for simple query

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Maksim Milyutin <milyutinma(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Slow planning time for simple query
Date: 2018-06-17 05:13:38
Message-ID: CAA4eK1+oP+RRG0uJSWpw=oFf3q3TPdhhRRp5byY7PSwK9H8sMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sun, Jun 10, 2018 at 1:19 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Maksim Milyutin <milyutinma(at)gmail(dot)com> 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,
>

I don't see anything like that in the code. We use _bt_killitems to
mark the items as dead and neither that function or any of its caller
has any such assumption.

> 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.
>

If my above understanding is correct, then one thing that could lead
to such behavior is the computation of RecentGlobalXmin on standby.
Basically, if the RecentGlobalXmin has a different value on standby,
then it is possible that the decision whether a particular item is
dead differs on master and 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.)
>

Because we don't WAL log it. See _bt_killitems.

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Amit Kapila 2018-06-17 05:15:35 Re: Slow planning time for simple query
Previous Message Justin Pryzby 2018-06-15 23:50:11 Re: ALTER TABLE SET (toast.asdf) is not rejected ... if a table has no toast

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2018-06-17 05:15:35 Re: Slow planning time for simple query
Previous Message Alvaro Herrera 2018-06-17 03:51:41 Re: Removing "Included attributes in B-tree indexes" section from docs