R: totally different plan when using partitions

From: Scara Maccai <m_lists(at)yahoo(dot)it>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: R: totally different plan when using partitions
Date: 2009-08-13 07:16:13
Message-ID: 709257.22033.qm@web24601.mail.ird.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Anyone??? This looks like a bug to me... or is there an explanation?

--- Mer 12/8/09, Scara Maccai <m_lists(at)yahoo(dot)it> ha scritto:

> Da: Scara Maccai <m_lists(at)yahoo(dot)it>
> Oggetto: [GENERAL] totally different plan when using partitions
> A: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
> Data: Mercoledì 12 agosto 2009, 13:05
>
> query using partitions explicitly ("1"):
>
> explain analyze
>     select nome1,
>     thv3tralacc,
>     dltbfpgpdch
>     FROM cell_bsc_60_0610 as cell_bsc
>         left outer join
> teststscell73_0610_1 as data on data.ne_id=cell_bsc.nome1
>         left outer join
> teststscell13_0610_1 as data1 on data1.ne_id=cell_bsc.nome1
> and data1.time=data.time 
>     where
>
>     data.time >=cell_bsc.starttime and
> data.time <=cell_bsc.endtime and   
>      data.time between '2006-10-01
> 00:00:00' and '2006-10-06 00:00:00'
> and    data1.time >=cell_bsc.starttime
> and data1.time <=cell_bsc.endtime
>      and   
> data1.time between '2006-10-01 00:00:00' and '2006-10-06
> 00:00:00'
>     and cell_bsc.nome2=2
>
> explain analyze:
>
> http://explain-analyze.info/query_plans/3805-query-plan-2509
>
>
> same query, but using postgresql's partition pruning
> ("2"):
>
> explain analyze
>     select nome1,
>     thv3tralacc,
>     dltbfpgpdch
>     FROM cell_bsc_60_0610 as cell_bsc
>         left outer join
> teststscell73 as data on data.ne_id=cell_bsc.nome1
>         left outer join
> teststscell13 as data1 on data1.ne_id=cell_bsc.nome1 and
> data1.time=data.time 
>     where
>
>     data.time >=cell_bsc.starttime and
> data.time <=cell_bsc.endtime and   
>      data.time between '2006-10-01
> 00:00:00' and '2006-10-06 00:00:00'
> and    data1.time >=cell_bsc.starttime
> and data1.time <=cell_bsc.endtime
>      and   
> data1.time between '2006-10-01 00:00:00' and '2006-10-06
> 00:00:00'
>     and cell_bsc.nome2=2
>
>
> explain analyze:
>
> http://explain-analyze.info/query_plans/3807-query-plan-2511
>
>
> The second version is A LOT slower (10x). But the 2 queries
> should be identical... why the two totally different
> plans???
>
> As you can see in query "1" I just put the used table, in
> query "2" postgres uses exactly the table I put in "1" (plus
> the empty tables that are the "father" of the other tables);
> so I don't understand why the 2 plans...

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2009-08-13 07:36:38 Re: totally different plan when using partitions
Previous Message arsi 2009-08-13 06:09:05 Encoding question when dumping/restoring databases for upgrade