Re: query from partitions - Mailing list pgsql-performance

From Steinar H. Gunderson
Subject Re: query from partitions
Date
Msg-id 20051213160852.GA3740@uio.no
Whole thread Raw
In response to query from partitions  (Ключников А.С. <alexs@analytic.mv.ru>)
List pgsql-performance
On Tue, Dec 13, 2005 at 06:18:19PM +0300, Ключников А.С. wrote:
> select * from base
>     where id in (select id from device where id = 1 or id = 2) and
>     datatime between '2005-05-15' and '2005-05-17';
> 10 minits

That's a really odd way of saying "1 or 2". It probably has to go through all
the records in device, not realizing it can just scan for two of them (using
two index scans). I'd guess an EXPLAIN ANALYZE would confirm something like
this happening (you'd want to run that and post the results here anyhow).

/* Steinar */
--
Homepage: http://www.sesse.net/

pgsql-performance by date:

Previous
From: Richard Huxton
Date:
Subject: Re: query from partitions
Next
From: Francisco Reyes
Date:
Subject: Re: Small table or partial index?