pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: marko@joh.to
To: pgsql-bugs@postgresql.org
Subject: BUG #14676: neqsel is NULL dumb
Date: Mon, 29 May 2017 15:38:47 +0000
Message-ID: <20170529153847.4275.95416@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14676
Logged by:          Marko Tiikkaja
Email address:      marko@joh.to
PostgreSQL version: 9.6.3
Operating system:   Linux
Description:        

I'm having an issue with a case where a column is mostly NULLs and I'm doing
an inequality query on the column:

=# create table foo(nullable int);
CREATE TABLE

=# insert into foo select case when i = 1 then i else null end from
generate_series(1, 1000) gs(i);
INSERT 0 1000

=# analyze foo;
ANALYZE

=# explain select * from foo where nullable <> 1;
                      QUERY PLAN
------------------------------------------------------
 Seq Scan on foo  (cost=0.00..16.50 rows=999 width=4)
   Filter: (nullable <> 1)
(2 rows)

This seems to be because neqsel() doesn't take at all into account that both
operators will exclude NULL rows, and does a simple  1.0 - eqsel().  This
also means that a partial index such as:

   create index on foo(othercolumn) where nullable <> 1

will never be used.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (5+ messages)  latest in thread

Message-ID: <20170529153847.4275.95416@wrigleys.postgresql.org>
Permalink:  ../20170529153847.4275.95416@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170529153847.4275.95416@wrigleys.postgresql.org

 · 

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: marko@joh.to
  Subject: Re: BUG #14676: neqsel is NULL dumb
  In-Reply-To: <20170529153847.4275.95416@wrigleys.postgresql.org>
  References: <20170529153847.4275.95416@wrigleys.postgresql.org>

* 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