您好我正在尝试对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
如何多次执行这样的select语句,例如1000看看运行需要多长时间(ms)?
答案 0 :(得分:2)
我同意草莓......我使用了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))