Perl模块:MySQL与DBI [英] Perl modules: MySQL vs DBI
问题描述
我们的许多自动化过程都使用perl,并且需要访问我们的MySQL数据库.我不愿意承认这一点,但是直到最近,我们仍未对大多数流程进行真正的基准测试.我们的一位开发人员设置了一个测试,将使用MySQL"与使用DBI"的性能与以下伪代码进行比较:
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
}
结果: MySQL-57秒,56秒,57秒 DBI-43s,42s,43s
Results: MySQL - 57s, 56s, 57s DBI - 43s, 42s, 43s
出于某种原因,我惊讶地发现DBI的性能如此之好;考虑我对这两个模块了解得很少.我意识到运行的基准测试可能有几处错误,每个人的设置/结果都将非常高,但是我很好奇其他人是否通过使用DBI和MySQL模块获得了任何形式的性能提升.
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.
推荐答案
我找到了 MySQL 模块,它 部分 DBD :: mysql dist.引用
I found the MySQL module he's referring to, it was part of the DBD::mysql dist. To quote it
自Msql-Mysql-modules 1.19_10起 M(y)sqlPerl不再是单独的 模块.而是使用 DBI驱动程序.你很坚强 鼓励与 直接使用DBI.
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.
因此,仿真层是造成性能下降的原因.另外,MySQL.pm
在DBD :: mysql的4.x行中被删除,它最后一次出现在2006年.
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.
这篇关于Perl模块:MySQL与DBI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!