Re: Perl::DBI and interval syntax [side question] - Mailing list pgsql-general

From MaXX
Subject Re: Perl::DBI and interval syntax [side question]
Date
Msg-id dkq75j$ctj$1@talisker.lacave.net
Whole thread Raw
In response to Perl::DBI and interval syntax  (Allen <dba@girders.org>)
Responses Re: Perl::DBI and interval syntax [side question]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Martijn van Oosterhout wrote:
> On Mon, Nov 07, 2005 at 05:58:04PM -0500, Tom Lane wrote:
>> Allen <dba@girders.org> writes:
>> > SELECT count(*) from post where post_ts >= current_date - interval ?
>> This is not right, and never has been right, even though it may have
>> accidentally failed to fail with some client libraries.  Try
>> CAST(? as interval)                  (SQL standard)
>> ?::interval                          (Postgres-ism)
[...]
> This seems to be an example of breakage caused by DBI switching from
> "substitute params in client" to "use new protocol to substitute params
> in server" (prepare/execute).
[...]
Can this be the cause of a huge loss of perf? I have the following query in
a Perl script using DBI + DBD::Pg, AutoCommit => 0:
SELECT stats_put_sources(?, ?, int4(?), int4(?))
This syntax runs almost 10x faster than:
SELECT stats_put_sources(?, ?, ?::int4, ?::int4)

I can find where is the real difference, maybe this protocol stuff. In the
facts the speed difference was so great that there were no need to use
EXPLAIN to know what was the best option.

N.B.: The stats_put_source(varchar,varchar,int4,int4) function is a rewrite
of the INSERT OR UPDATE function described in the docs.

Thanks,
--
MaXX


pgsql-general by date:

Previous
From: Zlatko Matić
Date:
Subject: autovacuum,8.1, Win
Next
From: "Evandro's mailing lists (Please, don't send personal messages to this address)"
Date:
Subject: Re: Beyond the 1600 columns limit on windows