我在AWS RDS的生产环境中运行的旧版本MySQL(包括8.0.21)没有遇到过这个问题。我有一个查询,一年只运行一次。相关代码如下:
create table medicare_fee_history (
year int unsigned,
mac int unsigned,
locality int unsigned,
hcpcs varchar(10),
modifier varchar(10),
index (mac, locality, hcpcs, modifier),
non_facility decimal(17, 4),
facility decimal(17, 4)
) engine = myisam;
load data local infile 'PFALL.csv'
into table medicare_fee_history
fields terminated by ',' enclosed by '"'
(year, mac, locality, hcpcs, modifier, non_facility, facility);
create table medicare_fee_first (
year int unsigned,
hcpcs varchar(10),
modifier varchar(10),
index (hcpcs, modifier),
facility decimal(17, 4),
non_facility decimal(17, 4)
) engine = myisam;
insert into medicare_fee_first (year, hcpcs, modifier, facility, non_facility)
(
select min(year), hcpcs, modifier, avg(facility), avg(non_facility)
from medicare_fee_history group by hcpcs, modifier
);
在插入选择期间,出现以下错误:
错误1114(HY 000):表“/tmp/#sql4984_9_3”已满
表medicare_fee_history有16042724行。要重现此情况,可以在https://drive.google.com/file/d/1p7Yf7wsCnBXl7UaxeFC1AP0youl-KCdZ/view?usp=sharing中找到数据集
这个查询通常返回10823行。如果去掉avg(facility)和avg(non_facility),它似乎可以工作。/tmp中有足够的空间。100 G中有92%是空闲的。我将tmp_table_size设置为max。以下是当前的服务器设置:
mysql> show variables like '%tmp%';
+---------------------------------+----------------------+
| Variable_name | Value |
+---------------------------------+----------------------+
| default_tmp_storage_engine | InnoDB |
| innodb_tmpdir | |
| internal_tmp_mem_storage_engine | TempTable |
| slave_load_tmpdir | /tmp |
| tmp_table_size | 18446744073709551615 |
| tmpdir | /tmp |
+---------------------------------+----------------------+
6 rows in set (0.00 sec)
mysql> show variables like '%temp%';
+-----------------------------+-----------------------+
| Variable_name | Value |
+-----------------------------+-----------------------+
| avoid_temporal_upgrade | OFF |
| innodb_temp_data_file_path | ibtmp1:12M:autoextend |
| innodb_temp_tablespaces_dir | ./#innodb_temp/ |
| show_old_temporals | OFF |
| temptable_max_mmap | 1073741824 |
| temptable_max_ram | 1073741824 |
| temptable_use_mmap | ON |
+-----------------------------+-----------------------+
7 rows in set (0.00 sec)
有什么解决办法吗?
1条答案
按热度按时间jgzswidk1#
我认为您需要调整的相关设置是
temptable_max_mmap
请参阅:https://docs.amazonaws.cn/en_us/AmazonRDS/latest/AuroraUserGuide/ams3-temptable-behavior.html
实施例一
您知道临时表的累积大小将增长到20 GiB。您希望将内存中的临时表设置为2 GiB,并在磁盘上最多增长到20 GiB。
将temptable_max_ram设置为2,147,483,648,将temptable_max_mmap设置为21,474,836,480。这些值以字节为单位。