Re: PsqlODBC slow on UNION queries - Mailing list pgsql-odbc

From Tom Lane
Subject Re: PsqlODBC slow on UNION queries
Date
Msg-id 25908.1136783922@sss.pgh.pa.us
Whole thread Raw
In response to PsqlODBC slow on UNION queries  (Zoltan Boszormenyi <zboszor@dunaweb.hu>)
Responses Re: PsqlODBC slow on UNION queries
List pgsql-odbc
Zoltan Boszormenyi <zboszor@dunaweb.hu> writes:
> We have some large views, consisting of 6+ UNION members.
> Recently, I rewrote them to use UNION ALL, since the members
> give distinct rows across the whole view.

> The performance difference between the two is enormous, e.g. using UNION,
> the rows starts flowing only after 30-32 seconds but when using UNION ALL,
> it starts instantly.

Well, UNION requires fetching all the source rows and then doing a
duplicate-elimination step (sort+uniq basically).  Why does the
performance change surprise you?

            regards, tom lane

pgsql-odbc by date:

Previous
From: Zoltan Boszormenyi
Date:
Subject: PsqlODBC slow on UNION queries
Next
From: Zoltan Boszormenyi
Date:
Subject: Re: PsqlODBC slow on UNION queries