Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 34F0D9F985A for ; Thu, 23 Aug 2007 04:38:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 14967-10 for ; Thu, 23 Aug 2007 04:37:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.trinitydigital.com.au (mail.trinitydigital.com.au [202.134.38.99]) by postgresql.org (Postfix) with ESMTP id DF7539F984A for ; Thu, 23 Aug 2007 04:37:58 -0300 (ADT) Received: from [172.17.73.17] (C-59-101-146-253.mel.connect.net.au [59.101.146.253]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.trinitydigital.com.au (Postfix) with ESMTP id 5FA049B9E; Thu, 23 Aug 2007 17:37:38 +1000 (EST) Message-ID: <46CD3869.90600@pws.com.au> Date: Thu, 23 Aug 2007 17:34:01 +1000 From: Russell Smith User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: Michael Glaesemann CC: Stephen Davies , pgsql-performance@postgresql.org Subject: Re: Optimising "in" queries References: <200708221210.36770.scldad@sdc.com.au> <46CC16F3.7060606@pws.com.au> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/257 X-Sequence-Number: 26387 Michael Glaesemann wrote: > > On Aug 22, 2007, at 5:58 , Russell Smith wrote: > >> Stephen Davies wrote: >>> select count(rdate),rdate from reading where sensor_id in >>> (1137,1138,1139,1140) group by rdate order by rdate desc limit 1; >>> >>> >> It would have been helpful to see the table definition here. I can >> say up front that array processing in postgres is SLOW. > > Um, what array processing are you seeing here? IN (a, b, b) is not an > array construct. Filter: (sensor_id = ANY ('{1137,1138,1139,1140}'::integer[])) I've never seen this plan item except for when array's are involved. I could be wrong. I'd like to know how this is generated when you don't have an array. Regards Russell Smith