Re: index usage on queries on inherited tables

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Joseph Shraibman <jks(at)selectacast(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: index usage on queries on inherited tables
Date: 2011-04-28 02:18:37
Message-ID: 4DB8CE7D.8030503@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Joseph Shraibman wrote:
> In a 52 gig table I have a "select id from table limit 1 order
> by id desc" returns instantly, but as soon as you declare a child table
> it tries to seq scan all the tables.
>

This is probably the limitation that's fixed in PostgreSQL 9.1 by this
commit (following a few others leading up to it):
http://archives.postgresql.org/pgsql-committers/2010-11/msg00028.php

There was a good example showing what didn't work as expected before
(along with an earlier patch that didn't everything the larger 9.1
improvement does) at
http://archives.postgresql.org/pgsql-hackers/2009-07/msg01115.php ;
"ORDER BY x DESC LIMIT 1" returns the same things as MAX(x).

It's a pretty serious issue with the partitioning in earlier versions.
I know of multiple people, myself included, who have been compelled to
apply this change to an earlier version of PostgreSQL to make larger
partitioned databases work correctly. The other option is to manually
decompose the queries into ones that target each of the child tables
individually, then combine the results, which is no fun either.

--
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 HSIEN-WEN CHU 2011-04-28 03:33:44 VX_CONCURRENT flag on vxfs( 5.1 or later) for performance for postgresql?
Previous Message Sok Ann Yap 2011-04-28 00:19:01 Re: reducing random_page_cost from 4 to 2 to force index scan