Is Class::DBI slow?
- From: ankur2080@xxxxxxxxx
- Date: 20 Apr 2006 09:57:27 -0700
Hi,
I asked a question to the beginners@xxxxxxxx but did not get any
response. So I am mailing to the appropriate group.
~~~~~
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 compared to DBI.
Is it me who is doing something wrong or Class::DBI is always slower(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?
BTW, I have ~40k records and using mysql 5.0.
*** using DBI ***
use strict;
use warnings;
use DBI();
my $dbh =
DBI->connect("DBI:mysql:database=scratch;host=blah","user","passwd");
my $sth = $dbh->prepare("SELECT field from table where user =
'user1'"); $sth->execute(); while (my $ref = $sth->fetchrow_hashref())
{
print $ref->{field}, "\n";
}
$sth->finish();
$dbh->disconnect();
## 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.
____Test::Personal____
package Test::Personal;
use base 'Test::DBI';
Test::Personal->table('table');
Test::Personal->columns(Primary => qw/user start_time/);
Test::Personal->columns(Others => qw/field/);
1;
_____Test::DBI_______
package Test::DBI;
use base 'Class::DBI';
Test::DBI->connection('dbi:mysql:database=scratch;host=blah', 'user',
'password');
1;
--Ankur
.
- Prev by Date: RE: DBD::Solid or DBD::ODBC with Solid
- Next by Date: Re: last insert id
- Previous by thread: DBD::Solid or DBD::ODBC with Solid
- Next by thread: sv_setpvn error in DBD::Sybase
- Index(es):
Relevant Pages
|