Re: table partitioning and select max(id)

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Tobias Brox <tobixen(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: table partitioning and select max(id)
Date: 2011-02-05 08:49:24
Message-ID: 4D4D0F14.7020500@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Tobias Brox wrote:
> I did test "select id from table order by id desc limit 1" on my parent table
> yesterday, it would still do the seq-scan. Even adding a
> where-restriction to make sure only one partition was queried I still
> got the seq-scan.
>

Right; you actually have to direct the query toward the specific
partition by name, nothing run against the parent table will work. The
new logic for 9.1 essentially splits the query into this alternate form,
runs it against every partition individually, then combines the
results. If you can afford to wait for 9.1, that is certainly the easy
path here. It just works out of the box in that version.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Віталій Тимчишин 2011-02-05 09:01:05 Re: How to best use 32 15k.7 300GB drives?
Previous Message Greg Smith 2011-02-05 08:49:05 Re: [HACKERS] Slow count(*) again...