【TiDB 版本】
5.7.25-TiDB-v5.2.3
【 TiDB 使用环境】
|组件|CPU|内存|本地存储|网络|
|TiDB|8 核+|16 GB+|SAS, 200 GB+|千兆网卡|
|PD|4 核+|8 GB+|SAS, 200 GB+|千兆网卡|
|TiKV|8 核+|32 GB+|SSD, 200 GB+|千兆网卡|
|TiFlash|32 核+|64 GB+|SSD, 200 GB+|千兆网卡|
【概述】 场景 + 问题概述
tidb_mem_quota_query设置了12G,分片插入执行了好几次,每次都是在3500s左右报Out Of Memory Quota![conn_id=13],我查询慢sql,发现慢sql表记录占用内存60G,可是我TIDB配置总共才16G,请问是什么原因呢???
插入的数据量在1千万左右。
sql较长,我简化成以下:
set @@SESSION.tidb_mem_quota_query = 12 << 30;
SET @@SESSION.tidb_batch_insert = 1;
SET @@SESSION.tidb_dml_batch_size = 5000;
INSERT INTO ods_order_item_base_two (
order_id,
item_no,
…
)
SELECT /*+ INL_JOIN(oi,oid,oie,ei,eica) */
oi.id AS order_id,
oi.item_no,
…
…
FROM
order_item oi
INNER JOIN order_item_details oid ON oi.item_no = oid.item_no
INNER JOIN order_item_extra oie ON oi.item_no = oie.item_no
INNER JOIN expenses_item ei ON ei.id = oi.setmanag_item_id
LEFT JOIN expenses_item_client_authorization eica ON eica.expenses_item_id = oi.setmanag_item_id AND eica.user_info_id = oi.merchant_code
where
0=0
and oi.cust_merch_id = 111267
AND oi.status_id IN( 80, 70)
AND oi.discrepant_data = 0