Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id EF6FBB5DC09 for ; Sat, 24 Sep 2011 06:38:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 69263-01 for ; Sat, 24 Sep 2011 09:38:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.23]) by mail.postgresql.org (Postfix) with SMTP id 873EAB5DBE1 for ; Sat, 24 Sep 2011 06:38:49 -0300 (ADT) Received: (qmail invoked by alias); 24 Sep 2011 09:38:47 -0000 Received: from mue-88-130-48-051.dsl.tropolys.de (EHLO [192.168.1.113]) [88.130.48.51] by mail.gmx.net (mp001) with SMTP; 24 Sep 2011 11:38:47 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX18ts71vcpAtjyaexIcwXnkmX427okbnCN6TmPRogn fbJauI23W22c31 Message-ID: <4E7DA528.9010902@gmx.net> Date: Sat, 24 Sep 2011 11:38:48 +0200 From: Andreas User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Better way to check more than 1 value NOT IN (...) Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.393 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-0.504, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201109/75 X-Sequence-Number: 35875 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?