简体   繁体   English

Perl模块:MySQL与DBI

[英]Perl modules: MySQL vs DBI

A lot of our automated processes use perl and need to access our MySQL DBs. 我们的许多自动化流程都使用perl,并且需要访问我们的MySQL数据库。 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: 我们的一位开发人员设置了一个测试,将“使用MySQL”与“使用DBI”的性能与以下伪代码进行比较:

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 结果:MySQL-57s,56s,57s DBI-43s,42s,43s

For some reason I was surprised to see DBI performing so much better; 由于某种原因,我惊讶地发现DBI的性能如此之好。 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. 我意识到运行的基准测试可能存在一些问题,每个人的设置/结果都将非常高,但是我很好奇其他人是否通过使用DBI和MySQL模块获得了任何形式的性能提升。

I found the MySQL module he's referring to, it was part of the DBD::mysql dist. 我找到了他所指的MySQL模块,它 DBD :: mysql dist的一部分。 To quote it 引用它

As of Msql-Mysql-modules 1.19_10 M(y)sqlPerl is no longer a separate module. 从Msql-Mysql-modules开始1.19_10 M(y)sqlPerl不再是单独的模块。 Instead it is emulated using the DBI drivers. 而是使用DBI驱动程序对其进行仿真。 You are strongly encouraged to implement new code with DBI directly. 强烈建议您直接使用DBI实施新代码。

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. 另外,在DBD :: mysql的4.x行中删除了MySQL.pm ,它的上一次出现在2006年。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM