Re: LIMIT on partitioned-table!?

From: Shaun Thomas <sthomas(at)peak6(dot)com>
To: "Kim A(dot) Brandt" <kimabrandt(at)gmx(dot)de>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: LIMIT on partitioned-table!?
Date: 2011-02-15 14:49:37
Message-ID: 4D5A9281.4010605@peak6.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 02/15/2011 08:23 AM, Kim A. Brandt wrote:

> does `postgres (PostgreSQL) 8.4.5' use the LIMIT of a query when it
> is run on a partitioned-table or am I doing something wrong? It looks
> as if postgres queries all partitions and then LIMITing the records
> afterwards!? This results in a long (>3 minutes) running query. What
> can I do to optimise this?

Make sure you have constraint_exclusion set to 'on' in your config.
Also, what are your checks for your partitions? You've got a pretty wide
range in your 'ts' checks, so if you're using them as your partition
definition, you're not helping yourself.

The main issue might just be that you've used an order clause. LIMIT
1000 or not, even if it can restrict the result set based on your CHECK
criteria, it'll still need to select every matching row from every
matched partition, order the results, and chop off the first 1000.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas(at)peak6(dot)com

______________________________________________

See http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Thomas Pöhler 2011-02-15 17:19:14 high user cpu, massive SELECTs, no io waiting problem
Previous Message Kim A. Brandt 2011-02-15 14:23:40 LIMIT on partitioned-table!?