Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 04966B5D90E for ; Mon, 23 May 2011 12:55:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 77792-07 for ; Mon, 23 May 2011 15:54:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gy0-f174.google.com (mail-gy0-f174.google.com [209.85.160.174]) by mail.postgresql.org (Postfix) with ESMTP id 5ABA3B5D8BD for ; Mon, 23 May 2011 12:54:53 -0300 (ADT) Received: by gyd10 with SMTP id 10so2140121gyd.19 for ; Mon, 23 May 2011 08:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=xHfK8NLVCV2qNLyBlq55N4FjtuM761UQfCMOwY1ZC+w=; b=Dt+DvwyQo4Tq5YujNbgz+mqMvlmHtamGD6dG8fwGKi37Z2RY+xZmLo8DMeWlFhHYUW T1zui3+kHXqKX2wMfbFZyqljk7FQXN2OUKqoaRUaDYsRW6kPdy6rALrP8j9+CUgOrPo+ J0dSihfJ+WDn6i9zas3l8B0B7R8xxXMkI5wwA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=tr49eZiect2s46gd5oJ3h6kP6V+4JxnH1MRmlzmvZ1yAX3q9GEaJ7xnVI+sXci3LwA OKehCZLrIbEuD4hsJYDd6djmCcA9Mn/O4EDPHaW032Cwe9T7GS+Hbf9UXWUmTuVyIM8L 5CRV6cSs/5pTn8jw8ufb4TxjC1fdCYQBwjcdQ= MIME-Version: 1.0 Received: by 10.236.201.200 with SMTP id b48mr3247466yho.210.1306166092396; Mon, 23 May 2011 08:54:52 -0700 (PDT) Received: by 10.236.208.138 with HTTP; Mon, 23 May 2011 08:54:52 -0700 (PDT) In-Reply-To: References: Date: Mon, 23 May 2011 08:54:52 -0700 Message-ID: Subject: Re: Pushing LIMIT into sub-queries of a UNION ALL? From: Dave Johansen To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=20cf305e240ff479ae04a3f37ddf X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.887 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201105/300 X-Sequence-Number: 43809 --20cf305e240ff479ae04a3f37ddf Content-Type: text/plain; charset=ISO-8859-1 I apologize for the multiple posts. I sent this email right after joining the list and after it hadn't shown up a day later I figured that it had been lost or something and sent the other one. Also, the database I posted this about does not have internet access and so I'm working on getting it moved over to a machine that does or getting it the info onto a machine where I can post the pertinent information about the schema and explain outputs. Thanks, Dave -- Dave Johansen phone: (520) 302-4526 On Sun, May 22, 2011 at 10:34 AM, Robert Klemme wrote: > Dave, > > how often do you want to repeat that posting? What about instead > replying to the answers you got so far? > > Cheers > > robert > > > On Tue, May 17, 2011 at 5:31 PM, Dave Johansen > 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? > > > > Thanks, > > Dave > > > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > --20cf305e240ff479ae04a3f37ddf Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I apologize for the multiple posts. I sent this email right after joining t= he list and after it hadn't shown up a day later I figured that it had = been lost or something and sent the other one.

Also, the database I = posted this about does not have internet access and so I'm working on g= etting it moved over to a machine that does or getting it the info onto a m= achine where I can post the pertinent information about the schema and expl= ain outputs.

Thanks,
Dave

--
Dave Johansen
phone: (520= ) 302-4526


On Sun, May 22, 2011 at 10:34 AM, Robert= Klemme <shortcutter@googlemail.com> wrote:
Dave,

how often do you want to repeat that posting? =A0What about instead
replying to the answers you got so far?

Cheers

robert


On Tue, May 17, 2011 at 5:31 PM, Dave Johansen <davejohansen@gmail.com> wrote:
> I am using Postgres 8.3 and I have an issue very closely related to th= e 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?
>
> Thanks,
> Dave



--
remember.guy do |as, often| as.you_can - without end
http://blo= g.rubybestpractices.com/

--20cf305e240ff479ae04a3f37ddf--