Search Postgresql Archives

Re: Perl::DBI and interval syntax [side question]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martijn van Oosterhout wrote:
> On Mon, Nov 07, 2005 at 05:58:04PM -0500, Tom Lane wrote:
>> Allen <dba@xxxxxxxxxxx> 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


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux