Re: Partitioned Tables and ORDER BY

From: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
To: Michal Szymanski <mich20061(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Partitioned Tables and ORDER BY
Date: 2009-10-19 08:24:45
Message-ID: 2f4958ff0910190124k2a25317btcc0db14b39712e0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sun, Oct 11, 2009 at 3:30 PM, Michal Szymanski <mich20061(at)gmail(dot)com>wrote:

> We have similar problem and now we are try to find solution. When you
> execute query on partion there is no sorting - DB use index to
> retrieve data and if you need let say 50 rows it reads 50 rows using
> index. But when you execute on parent table query optymizer do this:
>
> -> Sort (cost=726844.88..748207.02 rows=8544855 width=37739)
> (actual time=149864.868..149864.876 rows=50 loops=1)
>
> it means 8544855 rows should be sorted and it takes long minutes.

The figures in first parenthesis are estimates, not the actual row count.
If you think it is too low, increase statistic target for that column.

We
> have simpler situation than you and I will try to find solution
> tommorow :)
>
> Michal Szymanski
> http://blog.szymanskich.net
> http://techblog.freeconet.pl/
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance
>

--
GJ

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Matthew Wakeling 2009-10-19 09:35:55 Re: Issues with \copy from file
Previous Message Robert Haas 2009-10-19 00:52:34 Re: Performance with sorting and LIMIT on partitioned table