pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: mayur555b@protonmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16130: planner does not pick unique btree index and goes for seq scan but unsafe hash index works.
Date: Thu, 21 Nov 2019 12:48:00 -0500
Message-ID: <23661.1574358480@sss.pgh.pa.us> (raw)
In-Reply-To: <16130-d936946edf14de14@postgresql.org>
References: <16130-d936946edf14de14@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> writes:
> Planner does not pick unique btree index and goes for seq scan but unsafe
> hash index works.

I couldn't reproduce this from the given instructions.

Looking at the code, it looks like it might be possible to explain it
with a combination of (1) old_snapshot_threshold being enabled (not -1),
and (2) something holding back global xmin, such as a long-running
transaction.  (Maybe you have an uncommitted prepared transaction?)
In that situation a newly-created index won't be used until all older
transactions have gone away.  But the existence of an unlogged index
(hash index) disables the snapshot threshold feature for the associated
table.

There may be some additional condition needed to cause it, because
I still couldn't reproduce the behavior with those two conditions
set up.

IMO old_snapshot_threshold is a complete kluge and you should not
have it turned on unless you desperately need it.  It has a lot of
poorly-documented drawbacks, including this one.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <23661.1574358480@sss.pgh.pa.us>
Permalink:  ../23661.1574358480@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23661.1574358480@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mayur555b@protonmail.com
  Subject: Re: BUG #16130: planner does not pick unique btree index and goes for seq scan but unsafe hash index works.
  In-Reply-To: <23661.1574358480@sss.pgh.pa.us>
  References: <16130-d936946edf14de14@postgresql.org> <23661.1574358480@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox