Re: Pushing LIMIT into sub-queries of a UNION ALL

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Dave Johansen <davejohansen(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Pushing LIMIT into sub-queries of a UNION ALL
Date: 2011-05-23 17:21:17
Message-ID: BANLkTi=kf74TbkbZpxuFQmE_Y9yXpHizzw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, May 16, 2011 at 3:38 PM, Dave Johansen <davejohansen(at)gmail(dot)com> wrote:
> I am using Postgres 8.3 and I have an issue very closely related to the one
> described here:
> http://archives.postgresql.org/pgsql-general/2005-06/msg00488.php
>
> Basically, I have a VIEW which is a UNION ALL of two tables but when I do a
> select on the view using a LIMIT, it scans the entire tables and takes
> significantly longer than writing out the query with the LIMITs in the
> sub-queries themselves. Is there a solution to get the view to perform like
> the sub-query version?

I believe this is fixed by MergeAppend in 9.1. You might want to try
9.1beta1 and see if that works better for you.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2011-05-23 17:27:13 Re: SORT performance - slow?
Previous Message Robert Haas 2011-05-23 17:19:48 Re: FW: KVP table vs. hstore - hstore performance (Was: Postgres NoSQL emulation)