Re: DBD-DBM too slow



ManKyu 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
.



Relevant Pages

  • Re: Why is C# 450% slower than C++ on nested loops ??
    ... The posted benchmark was crucial to ... > compilers generate for the loop and get over with it. ... > additions in the outer loops, which the C# compiler doesn't. ... gotten around to implementing every possible optimization in every language, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Bit-order reversal (little-endian <--> big-endian)
    ... The only thing I did with your do loop is ... copy and paste it into a benchmark app. ... Certainly you can use a standard if then statement instead of the IIF. ... design is faster as it avoids extra iterations. ...
    (microsoft.public.vb.general.discussion)
  • Re: FreeBSD mysql Benchmark on 4BSD/ULE scheduler and i386/amd64
    ... really only have a maximum of one client accessing your database then ... This being mysql, the number of processors isn't going to matter much, no matter how many connections you have. ... I've had my doubts about this "benchmark" from the beginning of this thread, I don't see the point of benchmarks using mysql - especially if it's not even clear whether myIsam or Innodb was used. ... It also scales almost linearly to the number of cpu's, provided there are enough simultaneous connections. ...
    (freebsd-stable)
  • Re: Test cpu speed
    ... Certainly if you run this benchmark on two CPUs with exactly the same ... CPU will run these faster. ... possibly exceeding the instruction cache. ... As the loop contents ...
    (comp.soft-sys.matlab)
  • XML to mySQL - Loop issue?
    ... I am trying to loop through a ... XML feeds, pull out some info and place it into a mySQL table. ...
    (comp.lang.php)