序号 | 是否预处理 | 语句 | 是否远程数据库 | 返回数据量 | 每次实验语句执行总次数 | 三次实验平均总耗时/单位毫秒 |
1 | 是 | select * from task where task.taskId in (?) | 是 | 1000 | 1000 | 69822 |
2 | 否 | select * from task where task.taskId in (arr) | 是 | 1000 | 1000 | 66778 |
3 | 是 | select * from task where task.taskId = ? | 是 | 1 | 1000 | 1260 |
4 | 否 | select * from task where task.taskId = id | 是 | 1 | 1000 | 951 |
5 | 是 | select * from task a LEFT JOIN task_file b ON a.taskId = b.task_id where a.taskName like '%s%' and b.file_id > 100000 and b.file_id < 200000 and a.taskId = ?"; | 是 | 2 | 1000 | 2130 |
6 | 否 | select * from task a LEFT JOIN task_file b ON a.taskId = b.task_id where a.taskName like '%s%' and b.file_id > 100000 and b.file_id < 200000 and a.taskId = 32327"; | 是 | 2 | 1000 | 1480 |
7 | 是 | select * from task where task.taskId in (?) | 否 | 1000 | 1000 | 57051 |
8 | 否 | select * from task where task.taskId in (arr) | 否 | 1000 | 1000 | 56235 |
9 | 是 | select * from task where task.taskId = ? | 否 | 1 | 1000 | 217 |
10 | 否 | select * from task where task.taskId = id | 否 | 1 | 1000 | 204 |
11 | 是 | select * from task a LEFT JOIN task_file b ON a.taskId = b.task_id where a.taskName like '%s%' and b.file_id > 100000 and b.file_id < 200000 and a.taskId = ?"; | 否 | 2 | 1000 | 366 |
12 | 否 | select * from task a LEFT JOIN task_file b ON a.taskId = b.task_id where a.taskName like '%s%' and b.file_id > 100000 and b.file_id < 200000 and a.taskId = 32327"; | 否 | 2 | 1000 | 380 |
6、结论
实验的数据结果和我预期的相差有点儿大,但经过反复检查测试代码和测试过程,确认测试本身应该没有问题。尊重实验数据,我们得出以下结论:
1、通过实验5和实验6对比,实验11和实验12对比,可得猜想1是错误的。结论应该是:MySQL预处理和常规查询在简单语句和复杂语句下,都没有显著性的性能差别。
2、通过实验1和实验2对比,实验7和实验8对比,可得猜想2是错误的。结论应该是:MySQL预处理和常规查询的结果在数据传输上没有显著性的性能差距。
3、此外,对比远程数据库和本地数据库实验数据。可得结论:MySQL数据库在本地会给数据操作带来显著性的性能提高。
相关免费学习推荐:mysql数据库(视频)
以上就是介绍MySQL数据库的预处理(prepared statement)性能测试的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
更多相关阅读请进入《mysql》频道 >>
数据库系统概念 第6版
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。