query from partitions - Mailing list pgsql-performance

From Ключников А.С.
Subject query from partitions
Date
Msg-id 20051213151818.GA10021@mail.analytic.mv.ru
Whole thread Raw
Responses Re: query from partitions  (Richard Huxton <dev@archonet.com>)
Re: query from partitions  ("Steinar H. Gunderson" <sgunderson@bigfoot.com>)
List pgsql-performance
Hi.

create table device(id int);

insert into device values(1);
insert into device values(2);
.....
insert into device values(250);

create table base (
                    id int,
                    data float,
                    datatime timestamp,
                    mode int,
                    status int);

create table base_1 (
                    check ( id = 1 and datatime >= DATE '2005-01-01'
                    and datatime < DATE '2006-01-01' )
                    ) INHERITS (base);

create table base_2 (
                    check ( id = 2 and datatime >= DATE '2005-01-01'
                    and datatime < DATE '2006-01-01' )
                    ) INHERITS (base);
....
create table base_250


And
select * from base
    where id in (1,2) and datatime between '2005-05-15' and '2005-05-17';
10 seconds

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

Why?

--
mailto: alexs@analytic.mv.ru

pgsql-performance by date:

Previous
From: Marc Cousin
Date:
Subject: Re: partitioning
Next
From: Richard Huxton
Date:
Subject: Re: query from partitions