Class::DBI is sooooooooooo slow

Discussion in 'Perl Misc' started by ankur2080@gmail.com, Apr 21, 2006.

  1. Guest

    Last resort, posted this message to perl.beginners and perl.dbi.users
    and still didn't get a response. :-((.

    ~~~~

    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.

    FYI, 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
    , Apr 21, 2006
    #1
    1. Advertising

  2. jdrago_999 Guest

    jdrago_999, Apr 24, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ulloa
    Replies:
    1
    Views:
    515
    Juha Laiho
    Jul 22, 2004
  2. Jerome Hauss
    Replies:
    0
    Views:
    160
    Jerome Hauss
    Oct 13, 2004
  3. Asby

    Mason, DBI, and DBI::Pg

    Asby, Jul 24, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    167
  4. Tim Haynes
    Replies:
    3
    Views:
    132
    Ron Reidy
    Sep 13, 2003
  5. Replies:
    7
    Views:
    192
Loading...

Share This Page