设置Mysql sort_buffer_size参数
按照官网的解释:
Each session that must perform a sort allocates a buffer of this size. sort_buffer_size is not specific to any storage engine and applies in a general manner for optimization. At minimum the sort_buffer_size value must be large enough to accommodate fifteen tuples in the sort buffer. Also, increasing the value of max_sort_length may require increasing the value of sort_buffer_size. For more information, see Section 8.2.1.14, “ORDER BY Optimization”
sort_buffer_size 是一个connection级参数,在每个connection需要buffer的时候,一次性分配的内存。
sort_buffer_size 并不是越大越好,过大的设置+高并发可能会耗尽系统内存资源。
1.查看sort_buffer_size默认值,默认值为256K
mysql> show variables like 'sort_buffer_size';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| sort_buffer_size | 262144 |
+------------------+--------+
1 row in set (0.00 sec)
2.设置global级别的sort_buffer_size值,设置sort_buffer_size=1M
mysql> SET GLOBAL sort_buffer_size = 1024*1024;
Query OK, 0 rows affected (0.00 sec)
3.设置session级别的sort_buffer_size值,设置sort_buffer_size=2M
mysql> SET session sort_buffer_size = 2*1024*1024;
Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'sort_buffer_size';
+------------------+---------+
| Variable_name | Value |
+------------------+---------+
| sort_buffer_size | 2097152 |
+------------------+---------+
1 row in set (0.00 sec)
4.设置永久生效,需要修改/etc/my.cnf文件,重启Mysql后生效
[mysqld]
# 固定Mysql sort_buffer_size参数
sort_buffer_size=1M
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\mysql-8.0.25-winx64 # 切记此处一定要用双斜杠\\,单斜杠我这里会出错
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql-8.0.25-winx64\\data # data目录之后初始化会自动创建
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
设置Mysql sort_buffer_size参数的更多相关文章
- 设置Mysql的连接超时参数
在Mysql的默认设置中,如果一个数据库连接超过8小时没有使用(闲置8小时,即 28800s),mysql server将主动断开这条连接,后续在该连接上进行的查询操作都将失败,将 出现:e ...
- 1201MySQL配置文件mysql.ini参数详解
转自http://www.cnblogs.com/feichexia/archive/2012/11/27/mysqlconf.html my.ini(Linux系统下是my.cnf),当mysql服 ...
- (转)MySQL配置文件mysql.ini参数详解、MySQL性能优化
本文转自:http://www.cr173.com/html/18331_1.html my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数 ...
- MySQL配置文件mysql.ini参数详解、MySQL性能优化
my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数. my.ini分为两块:Client Section和Server Section. ...
- MySQL配置文件mysql.ini参数详解
my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数. my.ini分为两块:Client Section和Server Section. ...
- mysql配置文件参数详解
(一) [client]port = 3306socket = /tmp/mysql.sock [mysqld]port = 3306socket = /tmp/mysql.sock basedir ...
- mysql服务器参数
mysql服务器参数: 配置是从上往下读取,同一个参数项,后边的配置项会覆盖前边的配置项 mysql获取配置信息路径: 命令行参数 mysqld_safe --datadir=/data/sq ...
- mysql内存参数整理和条调优以及内存统计
date:20140530auth:Jin 参考:http://dev.mysql.com/doc/refman/5.5/en/server-status-variables.html#http:// ...
- 第四课(2)——mysql配置参数讲解
*****************general***************** user 启动mysql domain的用户 port 数据库端口号 socket 数据库socket文件的路径 p ...
- mysql 常见参数
my.cnf[client] 对mysql的所有客端都生效的[mysql] 只对mysql这个命令有效了[mysqd][mysqld_multi] 多实例启动[mysqld_safe][mysqldN ...
随机推荐
- not eligible for getting processed by all BeanPostProcessors
描述 这个BUG大的起源是我上线以后,在后台看日志的时候发现一行奇怪的INFO日志: 2022-06-09 23:34:24 [restartedMain] [org.springframework. ...
- nuxt项目npm install 或安装sass时报错
初始化nuxt项目时,多人开发,同事提前安装的sass ,拉去代码初始化npm install 时提示gyp版本有问题.找了好多方法,最后还是将node.js版本降低了.原来是16.13.2降低为14 ...
- redis中获取区间数据及获取总条数
import redis REDIS_ITEMS_HOST: str = host REDIS_ITEMS_PASSWORD: str = pwd REDIS_ITEMS_DB: int = 4 #查 ...
- scanf 读入 string 注意点
在做题的时候需要读入字符串,但是又不想使用char 数组,于是采用string存储,当时遇到了scanf读取string失败,查阅资料后总结下. scanf是c的标准输入输出流,想要读入string, ...
- 关于LAB2中的assert
在LAB2中,测试类里会看到这样一句话 注释的意思是确保VM参数启用 -ea,这是个新东西,平时也没写过,我们来了解一下. assert不同于assertEquals这样的函数,是Java中的一个关键 ...
- EF调用sql语句
1.连接数据库 2.在Dal进行调用sql语句 public List<UserInfo> PageShow(out int totalcount,out int totalpage, s ...
- idea创建maven + tomcat项目
移动文件夹: 找到tomcat文件目录 配置完成,添加测试html文件: 运行 修改默认路径:
- sql server 计算时间差的一部分函数【转】
在做Sql Server开发的时候有时需要获取表中今天.昨天.本周.上周.本月.上月等数据,这时候就需要使用DATEDIFF()函数及GetDate()函数了.DATEDIFF ( datepart ...
- Bootstrap4布局(简要)
目录 什么是Bootstrap 布局基础 布局容器 相应断点 z-index 网格系统 12栅格 重排序 列偏移 弹性盒子 什么是Bootstrap Bootstrap是目前最流行的一套前端开发框架, ...
- 服务器安装node
卸载步骤[未安装请忽略] 1.卸载npm sudo npm uninstall npm -g 2.卸载node yum remove nodejs npm -y 安装步骤 1.下载 wget http ...