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 709729DC834 for ; Mon, 9 Jan 2006 01:38:12 -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 80543-02 for ; Mon, 9 Jan 2006 01:38:11 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from linux.dunaweb.hu (linux.dunaweb.hu [62.77.196.1]) by postgresql.org (Postfix) with ESMTP id 1D4759DC80C for ; Mon, 9 Jan 2006 01:38:10 -0400 (AST) Received: from localhost (linux.dunaweb.hu [127.0.0.1]) by linux.dunaweb.hu (Postfix) with ESMTP id 9F2B28E06DD; Mon, 9 Jan 2006 06:38:09 +0100 (CET) Received: from linux.dunaweb.hu ([127.0.0.1]) by localhost (linux.dunaweb.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08818-06; Mon, 9 Jan 2006 06:38:09 +0100 (CET) Received: from [81.17.177.202] (host-81-17-177-202.dunaweb.hu [81.17.177.202]) by linux.dunaweb.hu (Postfix) with ESMTP id 077408E06D3; Mon, 9 Jan 2006 06:38:09 +0100 (CET) Message-ID: <43C1FEEF.5060107@dunaweb.hu> Date: Mon, 09 Jan 2006 07:13:03 +0100 From: Zoltan Boszormenyi User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929) X-Accept-Language: hu-hu, hu, en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-odbc@postgresql.org Subject: Re: PsqlODBC slow on UNION queries References: <43C1F84A.90707@dunaweb.hu> <25908.1136783922@sss.pgh.pa.us> In-Reply-To: <25908.1136783922@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: amavisd-new at dunaweb.hu X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.016 required=5 tests=[AWL=0.016] X-Spam-Score: 0.016 X-Spam-Level: X-Archive-Number: 200601/70 X-Sequence-Number: 6885 Tom Lane írta: >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 > > Well, as I said, doing the same test from PSQL, the performance difference is much less. I was really asking about the difference between psql and PsqlODBC: psql(output to file) psqlodbc UNION total time: < 12 sec first row received after 30 seconds UNION ALL total time < 4 sec first row received instantly My question is, why does PsqlODBC does the same unique seach again, when the server already did it? Only this would explain the difference between the psql and PsqlODBC timings. Best regards, Zoltán Böszörményi