pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: stefan.kirchev@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #9007: List comparison
Date: Tue, 28 Jan 2014 08:56:34 +0000
Message-ID: <20140128085634.26701.33428@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:      9007
Logged by:          Stefan Kirchev
Email address:      stefan.kirchev@gmail.com
PostgreSQL version: 9.1.0
Operating system:   Linux Ubuntu Server
Description:        

Using two tables to extract differences fails to show any result.
Table `table1` has two column of type integer, table `table2` has the same
structure. Using the following query fails to show the expected result:

select * from table1 where (c1, c2) not in (select c1, c2 from table2);

Adding a dummy condition in the internal query helps in getting results:

select * from table1 where (c1, c2) not in (select c1, c2 from table2 where
c1 <> 0);

Consider c1 does not nave values equal to 0:

pnp=# select c1, c2 from table2 where c1 = 0;
 c1 | c2
----+----
(0 rows)

Tested on versions 8.4 and 9.1. Here are the query plans on v8.4:
pnp=# explain select * from table1 where (c1, c2) not in (select c1, c2 from
table2 where c1 <> 0);
                             QUERY PLAN
--------------------------------------------------------------------
 Seq Scan on table1  (cost=290.31..681.84 rows=9951 width=8)
   Filter: (NOT (hashed subplan))
   SubPlan
     ->  Seq Scan on table2  (cost=0.00..253.58 rows=14692 width=8)
           Filter: (c1 <> 0)
(5 rows)

pnp=# explain select * from table1 where (c1, c2) not in (select c1, c2 from
table2);
                             QUERY PLAN
--------------------------------------------------------------------
 Seq Scan on table1  (cost=253.57..645.11 rows=9951 width=8)
   Filter: (NOT (hashed subplan))
   SubPlan
     ->  Seq Scan on table2  (cost=0.00..216.66 rows=14766 width=8)
(4 rows)

pnp=#

In the query plan the rows shown are half of the real table records:

pnp=# select count(*) from table1;
 count
-------
 20880
(1 row)

pnp=# select count(*) from table2;
 count
-------
 15557
(1 row)

pnp=#

Is that a buffers size issue? The server is pretty powerful and handles a
much bigger tables of about 100GB without loosing breath.


-- 
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 (2+ messages)  latest in thread

Message-ID: <20140128085634.26701.33428@wrigleys.postgresql.org>
Permalink:  ../20140128085634.26701.33428@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20140128085634.26701.33428@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: stefan.kirchev@gmail.com
  Subject: Re: BUG #9007: List comparison
  In-Reply-To: <20140128085634.26701.33428@wrigleys.postgresql.org>
  References: <20140128085634.26701.33428@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