Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0036F650164 for ; Mon, 21 Jul 2008 15:46:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 96270-05 for ; Mon, 21 Jul 2008 15:46:05 -0300 (ADT) Received: from mx2.hub.org (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 1AE9664FD13 for ; Mon, 21 Jul 2008 15:46:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mx2.hub.org (Postfix) with ESMTP id CD39012A62E3 for ; Mon, 21 Jul 2008 15:45:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m6LIiXh2016164; Mon, 21 Jul 2008 14:44:33 -0400 (EDT) To: Craig James cc: valiouk@yahoo.co.uk, psql performance Subject: Re: Perl/DBI vs Native In-reply-to: <4884C633.5050506@emolecules.com> References: <768129.60859.qm@web25802.mail.ukl.yahoo.com> <4884C633.5050506@emolecules.com> Comments: In-reply-to Craig James message dated "Mon, 21 Jul 2008 10:24:03 -0700" Date: Mon, 21 Jul 2008 14:44:32 -0400 Message-ID: <16163.1216665872@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/192 X-Sequence-Number: 30792 Craig James writes: > Valentin Bogdanov wrote: >> I have ran quite a few tests comparing how long a query takes to >> execute from Perl/DBI as compared to psql/pqlib. No matter how many >> times I run the test the results were always the same. >> >> I run a SELECT all on a fairly big table and enabled the >> log_min_duration_statement option. With psql postgres consistently >> logs half a second while the exact same query executed with Perl/DBI >> takes again consistently 2 seconds. > The problem may be that your two tests are not equivalent. When Perl > executes a statement, it copies the *entire* result set back to the > client before it returns the first row. Sure, but so does psql (unless you've turned on the magic FETCH_COUNT setting). I think the theories about prepared versus literal statements were more promising; but I don't know DBI well enough to know exactly what it was sending to the server. regards, tom lane