pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Better way to check more than 1 value NOT IN (...)
2+ messages / 2 participants
[nested] [flat]

* Better way to check more than 1 value NOT IN (...)
@ 2011-09-24 09:38 Andreas <maps.on@gmx.net>
  2011-09-24 11:54 ` Re: Better way to check more than 1 value NOT IN (...) =?ISO-8859-2?Q?pasman_pasma=F1ski?= <pasman.p@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Andreas @ 2011-09-24 09:38 UTC (permalink / raw)
  To: pgsql-sql

Hi,
I've got to check if 2 values are not in a set that is dynamically 
calculated by a function.

The query looks like

select  some_id, ....
from .....
where   10  is not in ( select x from my_function (some_id))
and   20  is not in ( select x from my_function (some_id))

Is there a efficiency issue with calculating the set twice ?
Can I somehow check both (or more) values at once?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Better way to check more than 1 value NOT IN (...)
  2011-09-24 09:38 Better way to check more than 1 value NOT IN (...) Andreas <maps.on@gmx.net>
@ 2011-09-24 11:54 ` =?ISO-8859-2?Q?pasman_pasma=F1ski?= <pasman.p@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: pasman pasmaƄski @ 2011-09-24 11:54 UTC (permalink / raw)
  To: pgsql-sql

You can write condition in subquery:

where 0=(select count(*) from myfunction(id) where x in (10,20))



2011/9/24, Andreas <maps.on@gmx.net>:
> Hi,
> I've got to check if 2 values are not in a set that is dynamically
> calculated by a function.
>
> The query looks like
>
> select  some_id, ....
> from .....
> where   10  is not in ( select x from my_function (some_id))
> and   20  is not in ( select x from my_function (some_id))
>
> Is there a efficiency issue with calculating the set twice ?
> Can I somehow check both (or more) values at once?
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>


-- 
------------
pasman



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-09-24 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-09-24 09:38 Better way to check more than 1 value NOT IN (...) Andreas <maps.on@gmx.net>
2011-09-24 11:54 ` =?ISO-8859-2?Q?pasman_pasma=F1ski?= <pasman.p@gmail.com>

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