Re: SELECT...VIEW...UNION...LIMIT

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT...VIEW...UNION...LIMIT
Date: 2004-11-25 05:51:19
Message-ID: 873byy3294.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"Ed L." <pgsql(at)bluepolka(dot)net> writes:

> create view big_view as
> select *, 'big_table'::varchar as source from big_table
> union
> select *, 'small_table'::varchar as source from small_table;

Try "UNION ALL" instead of just "union"

The difference is that union has to avoid duplicates. If you want duplicates
to be included or know for certain there will be no duplicates then union all
is faster.

--
greg

In response to

Browse pgsql-general by date

  From Date Subject
Next Message JM 2004-11-25 06:00:32 HELP speed up my Postgres
Previous Message Miles Keaton 2004-11-25 05:12:45 why use SCHEMA? any real-world examples?