Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 单条 SQL 的内存使用阈值设置无效?
[TiDB Usage Environment] Production Environment
[TiDB Version] v6.1.1
[Encountered Issue]
Operation:
INSERT INTO xx
SELECT * FROM yy
LIMIT 2000000;
Behavior:
- The memory setting for a single SQL is 1G (default setting), but the actual memory usage of the SQL found in information_schema.processlist is 3.3G, which is very confusing. No matter how I adjust the limit number, the memory usage is always 3.3G.
- Additionally, from the logs, it appears that a thread of an operator is triggered and stopped periodically. Whether the SQL can complete execution depends on the race between the operation time and the operator stopping pace.
Testing:
Subsequently, I adjusted tidb_distsql_scan_concurrency to 12 (previously set to 24), and then when running the SQL again, the memory usage dropped by half to 1.6G.
Confusion:
The official documentation describes that the tidb_mem_quota_query parameter controls the memory usage of a single SQL, but it doesn’t mention its relation to tidb_distsql_scan_concurrency (scan concurrency). So how exactly does this tidb_mem_quota_query = 1G limit work?
[Attachments]