tidb-server就返回1000条数据占用内存达到26.4GB?

tidb version

5.3.0

查询的sql:

SELECT
  *
FROM
  pay_iap_receipt_detail
WHERE
  createTime < '2022-03-30 14:52:52.986'
  AND preOrderFlag IS false
  AND exchangeFlag IS false
LIMIT
  1000;

	id                       	task     	estRows	operator info                                                                                                      	actRows	execution info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       	memory 	disk
	Limit_9                  	root     	1000   	offset:0, count:1000                                                                                               	1000   	time:4.02s, loops:2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  	N/A    	N/A
	└─IndexLookUp_18         	root     	1000   	                                                                                                                   	1000   	time:4.02s, loops:1, index_task: {total_time: 34.5s, fetch_handle: 171.2ms, build: 119.8µs, wait: 34.3s}, table_task: {total_time: 1h0m25.7s, num: 15, concurrency: 5}                                                                                                                                                                                                                                                                                                                                                                                                                                                              	26.4 GB	N/A
	  ├─IndexRangeScan_14    	cop[tikv]	1000   	table:pay_iap_receipt_detail, index:idx_create_time(createTime), range:[-inf,2022-03-30 14:52:53), keep order:false	1145764	time:15.5ms, loops:252, cop_task: {num: 1, max: 2.43ms, proc_keys: 0, rpc_num: 1, rpc_time: 2.38ms, copr_cache_hit_ratio: 1.00}, tikv_task:{time:769ms, loops:1123}                                                                                                                                                                                                                                                                                                                                                                                                                                                                  	N/A    	N/A
	  └─Limit_17             	cop[tikv]	1000   	offset:0, count:1000                                                                                               	237536 	time:59m10s, loops:247, cop_task: {num: 1417, max: 1m32s, min: 5.68ms, avg: 2.55s, p95: 11.7s, max_proc_keys: 520, p95_proc_keys: 404, tot_proc: 2m50.1s, tot_wait: 1.5s, rpc_num: 1578, rpc_time: 1h42m56.2s, copr_cache_hit_ratio: 0.00}, backoff{tikvRPC: 57s, pdRPC: 1.28s, regionMiss: 946ms}, tikv_task:{proc max:237ms, min:0s, p80:97ms, p95:148ms, iters:3944, tasks:1417}, scan_detail: {total_process_keys: 237536, total_process_keys_size: 25185374639, total_keys: 244848, rocksdb: {delete_skipped_count: 26047, key_skipped_count: 22360, block: {cache_hit_count: 1458748, read_count: 149524, read_byte: 1.80 GB}}}	N/A    	N/A
	    └─Selection_16       	cop[tikv]	1000   	isfalse(u7pay.pay_iap_receipt_detail.exchangeflag), isfalse(u7pay.pay_iap_receipt_detail.preorderflag)             	237536 	tikv_task:{proc max:237ms, min:0s, p80:97ms, p95:148ms, iters:3944, tasks:1417}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      	N/A    	N/A
	      └─TableRowIDScan_15	cop[tikv]	1000   	table:pay_iap_receipt_detail, keep order:false                                                                     	237536 	tikv_task:{proc max:237ms, min:0s, p80:97ms, p95:148ms, iters:3944, tasks:1417}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      	N/A    	N/A

问题:
上面的sql语句竟然占用26.4GiB的内存,然后我把这条sql语句杀掉,tidb-server内存回收很缓慢,不知道为什么

感觉是不是5.3.0版本的tidb-server内存有泄漏

有什么大字段类型吗 比如blob text类的。可以如下分析下内存占用
curl -G tidb-ip:10080/debug/pprof/heap > heap.profile
然后使用go tool pprof db.heap.prof --> top命令查看

有大字段,两个列是大字段

但是只返回1000条数据量,怎么也不会占用26GB的内存

貌似没辙,我有个表600多万条longtext字段最大3M多,单独统计这个字段总大小也就4G多,200G的空闲内存能吃完,研发说也没好办法,有tiflash吗看看放到tiflash里能减少点内存不

感觉不可能啊,即使一行占用5MB,1000行也就5GB;难道不是按照返回的行数来计算的么

表没加到tiflash

返回是内存分配按chunk单位,具体就不太了解了

该主题在最后一个回复创建后60天后自动关闭。不再允许新的回复。