A lot of our automated processes use perl and need to access our MySQL DBs. I hate to admit it, but up until recently we haven't really done much benchmarking with the majority of our processes. One of our devs setup a test to compare the performance of "use MySQL" vs "use DBI" with the following pseudocode:
for ($i = 1; $i <= 1000; $i++) {
pull and store all records in a 4,000 record table
}
Results:
MySQL - 57s, 56s, 57s
DBI - 43s, 42s, 43s
For some reason I was surprised to see DBI performing so much better; considering how little I know about either of the modules. I realize that there are likely several things wrong with the benchmark that was run and that everyone's setups/results are going to very but I was curious whether others have experienced any sort of performance gain by using DBI vs the MySQL module.
解决方案
I found the MySQL module he's referring to, it was part of the DBD::mysql dist. To quote it
As of Msql-Mysql-modules 1.19_10
M(y)sqlPerl is no longer a separate
module. Instead it is emulated using
the DBI drivers. You are strongly
encouraged to implement new code with
DBI directly.
So the emulation layer is the reason for your performace loss. Also that the MySQL.pm was removed in 4.x line of DBD::mysql, it last appeared in 2006.