您好,我正在尝试对 mySql 数据库的选择性能进行基准测试。我想知道如何多次执行 select 语句。目前我有以下循环:
BEGIN
label1: LOOP
SET p1 = p1 - 1;
IF p1 > 0 THEN
SELECT * FROM FOOD WHERE ID = p1;
ITERATE label1;
END IF;
LEAVE label1;
END LOOP label1;
END
但是,当在 phpMyAdmin 中运行此存储过程时,它不会返回任何结果。
更新
存储过程代码
CREATE DEFINER=`root`@`localhost` PROCEDURE `mySelect`(IN `p1` INT)
DETERMINISTIC
BEGIN
label1: LOOP
SET p1 = p1 - 1;
IF p1 > 0 THEN
SELECT * FROM FOOD where id = p1;
ITERATE label1;
END IF;
LEAVE label1;
END LOOP label1;
END
如何多次执行这样的选择语句,例如1000 查看运行需要多长时间(毫秒)?
最佳答案
我同意草莓的观点...我使用了mysqlslap
>mysqlslap --concurrency=50 --iterations=5 --query=test1.sql --create-schema=test -uroot -p
Benchmark
Average number of seconds to run all queries: 0.031 seconds
Minimum number of seconds to run all queries: 0.031 seconds
Maximum number of seconds to run all queries: 0.031 seconds
Number of clients running queries: 50
Average number of queries per client: 1
在 test1.sql 中我写道:
SELECT * FROM food WHERE id=(1+ FLOOR(RAND() * 10))
关于mysql - 如何在mySql中多次执行select语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28012682/