From: Zoltan Boszormenyi <zboszor@dunaweb.hu>
To: Ludek Finstrle <luf@pzkagis.cz>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-odbc@postgresql.org
Subject: Re: PsqlODBC slow on UNION queries
Date: Mon, 09 Jan 2006 13:15:09 +0100
Message-ID: <43C253CD.8080501@dunaweb.hu> (raw)
In-Reply-To: <20060109085745.GC29135@soptik.pzkagis.cz>
References: <43C1F84A.90707@dunaweb.hu>
<25908.1136783922@sss.pgh.pa.us>
<43C1FEEF.5060107@dunaweb.hu>
<20060109085745.GC29135@soptik.pzkagis.cz>
Hi,
Ludek Finstrle írta:
>>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
>>
>>
>
>I suppose you have used Declare/Fetch turned on. Please try the same
>query in psql client. The exact query you can find in mylog output.
>It could be something like
>DECLARE CURSOR <CURSOR_NAME> FOR SELECT <your select>;
>FETCH FORWARD <number of rows to fetch at first time> FROM <CURSOR_NAME>;
>
>If you have used Server side prepare then query is already different.
>It use:
>PREPARE <plan_name>[(paremters types)] AS <query>;
>EXECUTE <plan_name> [(parameters)];
>
>Regards,
>
>Luf
>
>
At the moment I am at home, being sick, so I cannot tell which queries
PowerBuilder use.
But here are the above queries and their timings from psql,
this is on my home machine, so the timings are different from
what I quoted. 84693 rows were produced by SELECT *,
so that's the number I used in FETCH FORWARD.
[zozo@host-81-17-177-202 psql]$ cat q1.txt
select * from v_invoice_browse;
[zozo@host-81-17-177-202 psql]$ cat q2.txt
begin;
declare mycur1 cursor for select * from v_invoice_browse;
FETCH FORWARD 84693 FROM mycur1;
commit;
[zozo@host-81-17-177-202 psql]$ cat q3.txt
prepare plan1 as select * from v_invoice_browse;
execute plan1;
DECLARE CURSOR complained about being outside of a transaction
block, so I put it between BEGIN and COMMIT.
UNION ALL:
[zozo@host-81-17-177-202 psql]$ time psql -f q1.txt -U bolt bolt2 >r1.txt
real 0m5.663s
user 0m2.440s
sys 0m0.347s
[zozo@host-81-17-177-202 psql]$ time psql -f q2.txt -U bolt bolt2 >r2.txt
real 0m5.870s
user 0m2.480s
sys 0m0.354s
[zozo@host-81-17-177-202 psql]$ time psql -f q3.txt -U bolt bolt2 >r3.txt
real 0m5.981s
user 0m2.449s
sys 0m0.353s
UNION:
[zozo@host-81-17-177-202 psql]$ time psql -f q1.txt -U bolt bolt2 >r1.txt
real 0m10.237s
user 0m2.453s
sys 0m0.214s
[zozo@host-81-17-177-202 psql]$ time psql -f q2.txt -U bolt bolt2 >r2.txt
real 0m10.535s
user 0m2.480s
sys 0m0.241s
[zozo@host-81-17-177-202 psql]$ time psql -f q3.txt -U bolt bolt2 >r3.txt
real 0m10.488s
user 0m2.466s
sys 0m0.245s
The timings between UNION and UNION ALL comparing the same query
is about what I expected. But there isn't too much difference between
the different queries on the same view, so the PowerBuilder behaviour still
isn't clear to me.
BTW, the quoted timings in the previous post from psql and UNION
vs UNION ALL were taken on a 3GHz HT P4, running RedHat 9.
The client is Windows2000 with PsqlODBC 08.01.0106.
The above timings were on an Athlon 3200+, running FC3/x86-64.
Both servers are running PostgreSQL 8.1.1.
And the timing differences happen differently if I attach the view
in an Access database in Office2003 using PsqlODBC 8.01.0106.
This is on WinXP running in VMWare on the same machine as the PostgreSQL
server. E.g. the view opens in Access in about 7 seconds when I use
UNION ALL,
but it requires about 17 seconds if I use UNION. This was with both
Declare/Fetch and Server side prepare being OFF. Also the same with
only Server side prepare being ON.
If I set only Declare/Fetch or both to ON, opening the VIEW in Access
comes close to what I experinced in psql, e.g. it appears almost instantly
when using UNION ALL, and just under 7 seconds when using UNION.
I don't remember which ODBC settings I used for the Windows2000 client
and PowerBuilder, I am not near that machine. I will recheck it when
I get back to my workplace next monday.
Best regards,
Zoltán Böszörményi
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-odbc@postgresql.org
Cc: zboszor@dunaweb.hu, luf@pzkagis.cz, tgl@sss.pgh.pa.us
Subject: Re: PsqlODBC slow on UNION queries
In-Reply-To: <43C253CD.8080501@dunaweb.hu>
References: <43C1F84A.90707@dunaweb.hu> <25908.1136783922@sss.pgh.pa.us> <43C1FEEF.5060107@dunaweb.hu> <20060109085745.GC29135@soptik.pzkagis.cz> <43C253CD.8080501@dunaweb.hu>
* 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