Re: query from partitions

From: "Steinar H(dot) Gunderson" <sgunderson(at)bigfoot(dot)com>
To: Ключников А(dot)С(dot) <alexs(at)analytic(dot)mv(dot)ru>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: query from partitions
Date: 2005-12-13 16:08:52
Message-ID: 20051213160852.GA3740@uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Francisco Reyes 2005-12-13 16:08:55 Re: Small table or partial index?
Previous Message Richard Huxton 2005-12-13 15:59:11 Re: query from partitions