pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Maksym Boguk <maxim.boguk@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6278: Index scans on '>' condition on field with many NULLS
Date: Mon, 31 Oct 2011 10:37:38 -0400
Message-ID: <26438.1320071858@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoaF9uU0BGgLsje8Mz0AdgJ1=1Znyqbq3xewvz-S0dEHYg@mail.gmail.com>
References: <201110310339.p9V3dtIb015254@wwwmaster.postgresql.org>
	<CA+TgmoaF9uU0BGgLsje8Mz0AdgJ1=1Znyqbq3xewvz-S0dEHYg@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Oct 30, 2011 at 11:39 PM, Maksym Boguk <maxim.boguk@gmail.com> wrote:
>> Seems index scan cannot stop after finding first NULL during scan on '>'
>> condition, and doing scan through all 90% nulls in table.

> I can reproduce this.  I'm not sure whether it's a bug either, but it
> sure seems less than ideal.  I suppose the problem is that we are
> generating an index scan that starts at 0.9999 and runs through the
> end of the index, rather than stopping when it hits the first NULL.

I poked at this a bit last night.  The reason it's happening is that the
">" key is only marked SK_BT_REQBKWD, not SK_BT_REQFWD, so _bt_checkkeys
doesn't think it can stop when it hits the NULLs.  Right at the moment
it seems like we could mark that key with both flags, which leads to the
conclusion that two flags are unnecessary and we could get by with only
one direction-independent flag.  Which, if memory serves, is how it used
to be ... until I split the flag into two to fix some bug or other.  But
the regression tests still pass if you make _bt_mark_scankey_required
mark any required key with both flags (which is the zeroth-order version
of recombining them).  So either my analysis was wrong at the time,
or some later change has eliminated the need for two flags, or the
regression tests aren't covering the problematic case.  Will investigate
further once I've absorbed some caffeine.

			regards, tom lane



view thread (7+ messages)  latest in thread

Message-ID: <26438.1320071858@sss.pgh.pa.us>
Permalink:  ../26438.1320071858@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26438.1320071858@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, robertmhaas@gmail.com, maxim.boguk@gmail.com
  Subject: Re: BUG #6278: Index scans on '>' condition on field with many NULLS
  In-Reply-To: <26438.1320071858@sss.pgh.pa.us>
  References: <201110310339.p9V3dtIb015254@wwwmaster.postgresql.org> <CA+TgmoaF9uU0BGgLsje8Mz0AdgJ1=1Znyqbq3xewvz-S0dEHYg@mail.gmail.com> <26438.1320071858@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