[CDBI] Is Class::DBI slow?

Daniel Williams danielw at staff.iinet.net.au
Mon May 1 03:22:23 BST 2006

Hi Ankur,

Test::Personal->columns(Others => qw/field/);
Test::Personal->columns(Essential => qw/field/);

Should bridge the gap a little.

-----Original Message-----
From: classdbi-bounces at lists.digitalcraftsmen.net
[mailto:classdbi-bounces at lists.digitalcraftsmen.net] On Behalf Of Ankur
Sent: Friday, 28 April 2006 5:54 PM
To: ClassDBI at svr02.digitalcraftsmen.net
Subject: [CDBI] Is Class::DBI slow?

Hi All,

My first try with Class::DBI and DBI modules and I find that making a
query using Class::DBI takes much much more time than just DBI.

Is it me who is doing something wrong or Class::DBI is always slow(I
have kind of feeling that its me who is doing something wrong).

Also, I have another question.
Why do I need to specify the column names, primary keys in Class::DBI
while not in DBI? I mean, how is DBI module able to determine the
primary keys and other fields while Class::DBI not.

I have ~40k records and using mysql 5.0.

*** using DBI ***

use strict;
use warnings;
use DBI();

my $dbh =

my $sth = $dbh->prepare("SELECT field from table where user =
while (my $ref = $sth->fetchrow_hashref()) {
    print $ref->{field}, "\n";



## Returns the result in a flash

*** using Class::DBI ***

use strict;
use warnings;

use Test::Personal;
my @users = Test::Personal->search(user => "user1");

foreach my $u ( @users ){
    print $u->field, "\n";

## Returns the result very slowly.


package Test::Personal;
use base 'Test::DBI';

Test::Personal->columns(Primary => qw/user start_time/);
Test::Personal->columns(Others => qw/field/);



package Test::DBI;
use base 'Class::DBI';

Test::DBI->connection('dbi:mysql:database=scratch;host=blah', 'user',


BTW, I posted this message to perl.beginners, perl.dbi.users and
comp.lang.perl.misc. I did not get an answer but got a pointer to this


ClassDBI mailing list
ClassDBI at lists.digitalcraftsmen.net

More information about the ClassDBI mailing list