mysql 5.1:如何使用 benchmark() 命令来测试对存储过程的调用?

发布于 2024-09-14 17:35:38 字数 463 浏览 1 评论 0原文

我正在尝试对存储过程进行基准测试。

  select benchmark(100000000,(select 1));

该基准测试有效,

但以下基准测试无效:

do benchmark(1000,(call test_login_user('a')));

它产生以下错误:有

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'call xpofb_login_user('a')))' at line 1

任何想法如何解决该问题吗?

I'm trying to benchmark a stored procedure.

  select benchmark(100000000,(select 1));

this benchmark works

but the following benchmark doesn't:

do benchmark(1000,(call test_login_user('a')));

it produces the following error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'call xpofb_login_user('a')))' at line 1

any ideas how to resolve the issue ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝梦月影 2024-09-21 17:35:38

您不能使用 benchmark() 来执行此操作,但您可以创建一个存储过程来执行此操作。

这是一个例子:

delimiter $

create procedure benchmark_test_login_user (p_username varchar(100), 
  p_count int unsigned)
begin
  declare v_iter int unsigned;
  set v_iter = 0;
  while v_iter < p_count
  do
    call test_login_user(p_username);
    set v_iter = v_iter + 1;
  end while;
end $

delimiter ;

call benchmark_test_login_user('a',1000);

You can't do this with benchmark(), but you could create a stored procedure to do it.

Here's an example:

delimiter $

create procedure benchmark_test_login_user (p_username varchar(100), 
  p_count int unsigned)
begin
  declare v_iter int unsigned;
  set v_iter = 0;
  while v_iter < p_count
  do
    call test_login_user(p_username);
    set v_iter = v_iter + 1;
  end while;
end $

delimiter ;

call benchmark_test_login_user('a',1000);
心碎的声音 2024-09-21 17:35:38

您不能

http://dev.mysql。 com/doc/refman/5.0/en/information-functions.html#function_benchmark

只能使用标量表达式。尽管表达式可以是子查询,但它必须返回单列且最多返回单行。例如,如果表 t 具有多于一列或多于一行,则 BENCHMARK(10, (SELECT * FROM t)) 将失败。

You can't

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_benchmark

Only scalar expressions can be used. Although the expression can be a subquery, it must return a single column and at most a single row. For example, BENCHMARK(10, (SELECT * FROM t)) will fail if the table t has more than one column or more than one row.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文