X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 9C2239DC85B for ; Mon, 9 Jan 2006 01:18:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74189-04 for ; Mon, 9 Jan 2006 01:18:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 587F69DC807 for ; Mon, 9 Jan 2006 01:18:47 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k095Igqo025909; Mon, 9 Jan 2006 00:18:42 -0500 (EST) To: Zoltan Boszormenyi cc: pgsql-odbc@postgresql.org Subject: Re: PsqlODBC slow on UNION queries In-reply-to: <43C1F84A.90707@dunaweb.hu> References: <43C1F84A.90707@dunaweb.hu> Comments: In-reply-to Zoltan Boszormenyi message dated "Mon, 09 Jan 2006 06:44:42 +0100" Date: Mon, 09 Jan 2006 00:18:42 -0500 Message-ID: <25908.1136783922@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.075 required=5 tests=[AWL=0.075] X-Spam-Score: 0.075 X-Spam-Level: X-Archive-Number: 200601/69 X-Sequence-Number: 6884 Zoltan Boszormenyi 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