X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 44D959DC9B3 for ; Wed, 18 Jan 2006 08:50:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32934-08 for ; Wed, 18 Jan 2006 08:50:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fep01.ttnet.net.tr (mail.ttnet.net.tr [212.175.13.129]) by postgresql.org (Postfix) with ESMTP id 22AFE9DC9AC for ; Wed, 18 Jan 2006 08:50:45 -0400 (AST) Received: from alamut ([85.102.233.174]) by fep01.ttnet.net.tr with ESMTP id <20060118124638.KZHT1401.fep01.ttnet.net.tr@alamut>; Wed, 18 Jan 2006 14:46:38 +0200 Date: Wed, 18 Jan 2006 14:48:34 +0200 From: Volkan YAZICI To: Michael Glaesemann Cc: Ivan Steganov , pgsql-sql@postgresql.org Subject: Re: Matching several rows Message-ID: <20060118124834.GC578@alamut> References: <3578f52e0601172043s64561353i689350a1c5d4debb@mail.gmail.com> <20060118115517.GA578@alamut> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.1i X-NAI-Spam-Rules: 0 Rules triggered X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=2.008 required=5 tests=[AWL=-0.790, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, DNS_FROM_RFC_WHOIS=0.879, UPPERCASE_25_50=0] X-Spam-Score: 2.008 X-Spam-Level: ** X-Archive-Number: 200601/119 X-Sequence-Number: 23908 On Jan 18 09:33, Michael Glaesemann wrote: > On Jan 18, 2006, at 20:55 , Volkan YAZICI wrote: > >SELECT t.id > >FROM (SELECT id, sum(1) AS s > > FROM id_n_rights > > WHERE rights = ANY(ARRAY[2,5,10]) > > GROUP BY id) AS t > >WHERE t.s = 3; AFAICS, the bottleneck in above query is ANY(ARRAY[]) clause usage. Instead of that, if you replace «rights = ANY(ARRAY[2,5,10])» with «rights IN (2,5,10)» it's overhead decreases to 0.200-0.300ms domain. Regards.