Re: DBD-DBM too slow
am 23.08.2006 21:21:02 von jeffManKyu Han wrote:
> Hi. I installed DBD::DBM through cpan and everything seems fine.
> I wanted to benchmark DBD::DBM's performance, so I did simple test.
> I populate table that I created with 200000 integer and strings.
> In mysql, it was going almost 7000 inserts / sec
> but in DBD::DBM, the best I could get was 130/sec
>
Your tests are flawed see below. OTOH, DBD::DBM is unlikely to be able
to compete with MySQL or even SQLite for speed.
> Is there some optimization that I should do?
>
If your SQL needs are light, use DBI::SQL::Nano instead of
SQL::Statement. And, especially note the next point:
> foreach my $sql (@sql_i){
> my $sth = $dbh->prepare($sql);
> $sth->execute;
> $count++;
> if($count%2000 eq 0){
> mkUtil::printTime("$count");
> }
> }
>
In DBD::DBM, prepare() takes a fair amount of time. If you prepare once
outside the loop then execute many times in the loop using placeholders
you will gain *lots* of time. This is true of most DBDs but especially
true of DBD::DBM and other SQL::Statement based DBDs.
Also, you might consider using DBI's new profiling capabilities or even
Benchmark when doing tests.
--
Jeff