From: Dave Johansen <davejohansen@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Pushing LIMIT into sub-queries of a UNION ALL
Date: Mon, 16 May 2011 12:38:12 -0700
Message-ID: <BANLkTinpyHPbf_e3js7PhKtM6AbaX7+c4A@mail.gmail.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: davejohansen@gmail.com
Subject: Re: Pushing LIMIT into sub-queries of a UNION ALL
In-Reply-To: <BANLkTinpyHPbf_e3js7PhKtM6AbaX7+c4A@mail.gmail.com>
References: <BANLkTinpyHPbf_e3js7PhKtM6AbaX7+c4A@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox