Perl modules: MySQL vs DBI

柔情痞子 提交于 2019-12-25 04:42:13

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3419468/perl-modules-mysql-vs-dbi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!