pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPartitioned tables not using index for min and max 8.2.7?
3+ messages / 2 participants
[nested] [flat]
* Partitioned tables not using index for min and max 8.2.7?
@ 2009-07-01 16:42 Tim Haak <timh@lucidview.net>
0 siblings, 1 reply; 3+ messages in thread
From: Tim Haak @ 2009-07-01 16:42 UTC (permalink / raw)
To: pgsql-sql
Hi
I am running the following query again a partitioned table in 8.2.7. It
does index scans which is unexpected as there are indexes for the
log_date column.
min(log_date) from data.table
"Aggregate (cost=739932.02..739932.02 rows=1 width=8)"
" -> Append (cost=0.00..685106.21 rows=21930321 width=8)"
" -> Seq Scan on table (cost=0.00..33827.10 rows=1215710 width=8)"
" -> Seq Scan on table_yy2009mm03 table (cost=0.00..88056.39
rows=438839 width=8)"
" -> Seq Scan on table_yy2009mm04 table (cost=0.00..204606.67
rows=7344967 width=8)"
" -> Seq Scan on table_yy2009mm05 table (cost=0.00..159210.91
rows=5735091 width=8)"
" -> Seq Scan on table_yy2009mm06 table (cost=0.00..199393.74
rows=7195574 width=8)"
" -> Seq Scan on table_yy2009mm07 table (cost=0.00..11.40
rows=140 width=8)"
though if i run it only agains the one table it is significantly faster
and uses the index
select min(log_date) from only data.table
"Result (cost=0.06..0.07 rows=1 width=0)"
" InitPlan"
" -> Limit (cost=0.00..0.06 rows=1 width=8)"
" -> Index Scan using idx_table_log_date_only on table
(cost=0.00..68272.93 rows=1215710 width=8)"
" Filter: (log_date IS NOT NULL)"
Am I doing something wrong or is this expected.
I tried the old method of
SELECT col FROM table ORDER BY col DESC LIMIT 1
But it does not work either.
--
Tim Haak
Email: timh@lucidview.net
Tel: +27 12 658 9019
Attachments:
timh.vcf (text/x-vcard, 168B) download
begin:vcard
fn:Timothy Haak
n:Haak;Timothy
email;internet:timh@lucidview.net
tel;work:+27 12 658 9019
tel;cell:+27 83 778 7100
x-mozilla-html:TRUE
version:2.1
end:vcard
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Partitioned tables not using index for min and max 8.2.7?
@ 2009-07-01 17:44 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tim Haak <timh@lucidview.net>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2009-07-01 17:44 UTC (permalink / raw)
To: Tim Haak <timh@lucidview.net>; +Cc: pgsql-sql
Tim Haak <timh@lucidview.net> writes:
> I am running the following query again a partitioned table in 8.2.7. It
> does index scans which is unexpected as there are indexes for the
> log_date column.
The index min/max optimization only works on single tables at the
moment. Sorry.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Partitioned tables not using index for min and max 8.2.7?
@ 2009-07-02 09:31 Tim Haak <timh@lucidview.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tim Haak @ 2009-07-02 09:31 UTC (permalink / raw)
To: ; +Cc: pgsql-sql
Cool thanks then not something I'm doing wrong :). Is this going to be
changed or is changed in a latter version of postgres. (Do I need to do
and upgrade or write a work around :) )
Tom Lane wrote:
> Tim Haak <timh@lucidview.net> writes:
>
>> I am running the following query again a partitioned table in 8.2.7. It
>> does index scans which is unexpected as there are indexes for the
>> log_date column.
>>
>
> The index min/max optimization only works on single tables at the
> moment. Sorry.
>
> regards, tom lane
>
>
--
Tim Haak
Email: timh@lucidview.net
Tel: +27 12 658 9019
Attachments:
timh.vcf (text/x-vcard, 168B) download
begin:vcard
fn:Timothy Haak
n:Haak;Timothy
email;internet:timh@lucidview.net
tel;work:+27 12 658 9019
tel;cell:+27 83 778 7100
x-mozilla-html:TRUE
version:2.1
end:vcard
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2009-07-02 09:31 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-07-01 16:42 Partitioned tables not using index for min and max 8.2.7? Tim Haak <timh@lucidview.net>
2009-07-01 17:44 ` Tom Lane <tgl@sss.pgh.pa.us>
2009-07-02 09:31 ` Tim Haak <timh@lucidview.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox