[英]How to execute a select statement multiple times in mySql?
Hi i am trying to benchmark the select performance of mySql database. 嗨,我正在尝试基准测试mySql数据库的选择性能。 I am wondering how I can execute the select statement multiple times.
我想知道如何可以多次执行select语句。 At the moment I have the following loop :
目前,我有以下循环:
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
However when running this stored procedure in phpMyAdmin it returns no results. 但是,在phpMyAdmin中运行此存储过程时,它不会返回任何结果。
Update 更新资料
Stored procedure code 存储过程代码
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
How can I execute a select statement like this multiple times eg 1000 to see how long (ms) it takes to run? 我如何多次执行这样的select语句(例如1000)以查看运行需要多长时间(ms)?
I agree with strawberry... I used mysqlslap 我同意草莓...我用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
Inside test1.sql I wrote: 在test1.sql中,我写道:
SELECT * FROM food WHERE id=(1+ FLOOR(RAND() * 10))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.