dbTalk Databases Forums  

[BUGS] IN does not negate, exists does

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] IN does not negate, exists does in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Achilleus Mantzios
 
Posts: n/a

Default [BUGS] IN does not negate, exists does - 02-05-2004 , 10:33 AM







EXISTS and IN seem to work ok for:

dynacom=# SELECT count(*) from parts p where p.id in (select md.partid
from machdefs md);
count
-------
12656
(1 row)

dynacom=# SELECT count(*) from parts p where exists (select 1 from
machdefs md where md.partid = p.id);
count
-------
12656
(1 row)

Whereas IN seems to not working ok when negated as shown below:

dynacom=# SELECT count(*) from parts p where p.id not in (select md.partid
from machdefs md);
count
-------
0
(1 row)

dynacom=# SELECT count(*) from parts p where not exists (select 1 from
machdefs md where md.partid = p.id);
count
-------
291
(1 row)

dynacom=# SELECT version();
version
-----------------------------------------------------------------------------------------------------------
PostgreSQL 7.4.1 on i386-unknown-freebsd5.1, compiled by GCC gcc (GCC)
3.2.2 [FreeBSD] 20030205 (release)
(1 row)


On PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC 2.96, i get
identical results.

Is this a known issue? Addressed before?

--
-Achilleus


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] IN does not negate, exists does - 02-05-2004 , 11:13 AM






Achilleus Mantzios <achill (AT) matrix (DOT) gatewaynet.com> writes:
Quote:
Whereas IN seems to not working ok when negated as shown below:
If the sub-select returns any NULLs then this behavior is per SQL spec.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #3  
Old   
Achilleus Mantzios
 
Posts: n/a

Default Re: [BUGS] IN does not negate, exists does - 02-06-2004 , 02:16 AM



O kyrios Tom Lane egrapse stis Feb 5, 2004 :

Quote:
Achilleus Mantzios <achill (AT) matrix (DOT) gatewaynet.com> writes:
Whereas IN seems to not working ok when negated as shown below:

If the sub-select returns any NULLs then this behavior is per SQL spec.
Thanx a lot!

Quote:
regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly

--
-Achilleus


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.