ITPub博客

首页 > 数据库 > MySQL > MySQL基准测试Can't create more than max_prepared_stmt_count statements

MySQL基准测试Can't create more than max_prepared_stmt_count statements

原创 MySQL 作者:StevenBeijing 时间:2020-08-14 18:39:02 0 删除 编辑

测试环境 :MySQL 5.7.26

       用sysbench做MySQL基准测试,出现报错Can't create more than max_prepared_stmt_count statements。通过查阅相关资料。

       max_prepared_stmt_count 参数限制了同一时间在mysqld上所有session中prepared 语句的上限。 它的取值范围为“0 - 1048576”,默认为16382。

       mysql对于超出max_prepared_stmt_count的prepare语句就会报Can't create more than max_prepared_stmt_count statements (current value: 16382)"错误。

对于现场而言,可以先将这个值调大。

       一般而言,默认值应该是足够用的,因为现场的并发其实没有那么的大。一个可能的原因是应用端那边没有关闭prepared的语句。

直连后端MySQL执行如下命令。

mysql> SHOW GLOBAL STATUS LIKE 'com_stmt%';
+-------------------------+--------+
| Variable_name           | Value  |
+-------------------------+--------+
| Com_stmt_execute        | 435289 |
| Com_stmt_close          | 0      |
| Com_stmt_fetch          | 0      |
| Com_stmt_prepare        | 46000  |
| Com_stmt_reset          | 0      |
| Com_stmt_send_long_data | 0      |
| Com_stmt_reprepare      | 0      |
+-------------------------+--------+
7 rows in set (0.00 sec)

查看如下3个参数值:

Com_stmt_close               prepare语句关闭的次数

Com_stmt_execute           prepare语句执行的次数

Com_stmt_prepare           prepare语句创建的次数

通过以下命令修改max_prepared_stmt_count的值(该值可动态修改,也可在配置文件中指定后重启服务生效)

mysql> set global max_prepared_stmt_count=100000;
Query OK, 0 rows affected (0.00 sec)

但是本人通过修改MySQL5.7.26参数文件,重启MySQL服务,参数并未生效。




来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30135314/viewspace-2711945/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-02-10

  • 博文量
    244
  • 访问量
    325264