[Dbix-class] Performance Issue

Bill McCormick wpmccormick at gmail.com
Mon Feb 20 22:04:13 GMT 2012


Bill McCormick wrote, On 2/20/2012 10:30 AM:
> I just wrote a tiny little script, just using DBI and DBD::SQLite, and =

> there is no delay.
>
> #!/usr/bin/perl
>
> use strict;
>
> use DBI;
> use DBD::SQLite;
>
>
> my $recipes_sql =3D q/SELECT * FROM recipe/;
>
> my $dbfile=3D"/home/fiber/data/recipe.db3";
>
> my $dbh =3D DBI->connect("dbi:SQLite:$dbfile") or croak $DBI::errstr;
>
> my $recipe_ary_ref  =3D $dbh->selectall_arrayref($recipes_sql,{ Slice =3D=
> =

> {} });
>
> foreach my $recipe ( @$recipe_ary_ref ) {
>     print qq/$recipe->{ID} $recipe->{NAME}\n/;
> }
>
>
> Thanks!!
>
> Alexander Hartmaier wrote, On 2/20/2012 10:02 AM:
>> Are you sure you measure correctly?
>> Did you include Perl startup time by accident?
>>
>> Am 2012-02-20 16:09, schrieb Bill McCormick:
>>> I'm just getting started using DBIx::Class and I am a little surprised
>>> at performance (rather, lack there of).
>>>
>>> Perhaps I've missed some key point, index or other such thing, but it
>>> takes well over a second to get results on a single table that has
>>> very few records (<20).
>>>
>>> I am running on Debian Squeeze (Linux 2.6.33 i586) with perl (v5.10.1)
>>> and SQLite3 (3.7.3).
>>>
>>> If I export DBIC_TRACE=3D1 and then run the my script, I see this:
>>>
>>>      SELECT me.ID, me.NAME FROM recipe me:
>>>
>>> So then if I run that query in sqlite3, it is markedly faster. I
>>> understand that the DBIx::Class needs a little more time, this delay
>>> makes me think I must have missed something.
>>>
>>>
I added some metrics. There is a HUGE (~1.5 sec) difference that needs =

to be accounted for here. Either I'm doing something very wrong (very =

likely) or there is something very wrong with DBIx.

Each test starts with this:
BEGIN {
     print qq/***** Start Test *****\n/;
     $start =3D clock();
     print qq/Start: $start\n/;
}

The part that takes the longest is loading the DBIx::Schema compared to =

loading DBI & DBD, but even the DB connect an query takes longer.

use MyApp::Schema;

$tick =3D clock();
$ticktock =3D $tick - $start;
print qq/Load Use: $ticktock\n/;

compared to:
use DBI;
use DBD::SQLite;

$tick =3D clock();
$ticktock =3D $tick - $start;
print qq/Load Use: $ticktock\n/;

I appreciate any insight at all.

Thanks!!

Output here:
$:/home/fiber/www/cgi-bin# ./recipe-test-DBIx.pl;./recipe-test-DBI.pl
***** Start Test *****
Start: 0.08
Load Use: 1.12
Connect: 1.32
Query: 1.65
RECIPE 1
RECIPE 2
RECIPE 3
RECIPE 4
RECIPE 5
RECIPE 6
RECIPE 7
RECIPE 8
RECIPE 9
RECIPE 10
RECIPE 11
RECIPE 12
RECIPE 13
RECIPE 14
RECIPE 15
RECIPE 16
RECIPE 17
RECIPE 18
RECIPE 19
Complete: 1.66
***** Start Test *****
Start: 0.08
Load Use: 0.17
Connect: 0.18
Query: 0.19
1 RECIPE 1
2 RECIPE 2
3 RECIPE 3
4 RECIPE 4
5 RECIPE 5
6 RECIPE 6
7 RECIPE 7
8 RECIPE 8
9 RECIPE 9
10 RECIPE 10
11 RECIPE 11
12 RECIPE 12
13 RECIPE 13
14 RECIPE 14
15 RECIPE 15
16 RECIPE 16
17 RECIPE 17
18 RECIPE 18
19 RECIPE 19
Complete: 0.19


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120220/4aa=
55661/attachment.htm


More information about the DBIx-Class mailing list