Skip Menu |

This queue is for tickets about the Ima-DBI CPAN distribution.

Report information
The Basics
Id: 42244
Status: new
Priority: 0/
Queue: Ima-DBI

People
Owner: Nobody in particular
Requestors: baron [...] xaprb.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Do not use $dbh->ping
Date: Thu, 8 Jan 2009 21:37:02 -0500
To: bug-Ima-DBI [...] rt.cpan.org
From: "Baron Schwartz" <baron [...] xaprb.com>
The following line of code is a performance issue: not ($dbh && $dbh->FETCH('Active') && $dbh->ping)) { I do not know about other databases, but on MySQL this sends a ping command via the native protocol to the server. This is not a problem for MySQL's performance, but it is a serious problem for application performance in general. I'm not sure that this is necessarily the case in every application, but in typical usage patterns I see (and I have seen a lot) this design results in a ping before each query. It causes twice the number of round-trips to the server, which adds to latency. This really does matter for applications such as websites that make many calls to the database to generate a page. Programmers, even smart ones, don't know that just by using Class::DBI or any of the other modules that use Ima::DBI they are causing this to happen behind the scenes. The other problem with this code is that it's useless. Just because the ping succeeds is no guarantee the the following query will succeed. The connection can go away before the query is executed. Instead, the query failing should be caught and then the connection can be reopened and the query retried. I'm not sure that this can really be "fixed" inside of Ima::DBI per se, but perhaps there can be an environment variable or some other way to disable this behavior and make it possible to enable only optionally.