【TiDB 版本】:
3.0.5
慢查询SQL
慢SQL 执行计划
mysql> EXPLAIN ANALYZE SELECT
-> *
-> FROM
-> (
-> SELECT
-> code1,
-> code2,
-> normal_1,
-> seller_1,
-> ROW_NUMBER ( ) OVER ( ORDER BY id ) AS row_num
-> FROM
-> dc_f_d_s
-> WHERE
-> is_Del = '0'
-> ) t
-> WHERE
-> t.row_num > 1570000
-> LIMIT 10000;
+--------------------------------+------------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
| id | count | task | operator info | execution info | memory |
+--------------------------------+------------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
| Projection_13 | 10000.00 | root | pressure_pfizer.dc_f_d_s.code1, pressure_pfizer.dc_f_d_s.code2, pressure_pfizer.dc_f_d_s.normal_1, pressure_pfizer.dc_f_d_s.seller_1, row_num | time:5.676301489s, loops:11, rows:10000 | N/A |
| └─Limit_16 | 10000.00 | root | offset:0, count:10000 | time:5.675881734s, loops:11, rows:10000 | N/A |
| └─Selection_17 | 10000.00 | root | gt(row_num, 1570000) | time:5.675858976s, loops:10, rows:10000 | N/A |
| └─Window_18 | 10000.00 | root | row_number() over(order by pressure_pfizer.dc_f_d_s.id asc) | time:5.58979399s, loops:1543, rows:1580032 | N/A |
| └─Projection_23 | 1740137.10 | root | pressure_pfizer.dc_f_d_s.code1, pressure_pfizer.dc_f_d_s.code2, pressure_pfizer.dc_f_d_s.normal_1, pressure_pfizer.dc_f_d_s.seller_1, pressure_pfizer.dc_f_d_s.is_Del, pressure_pfizer.dc_f_d_s.id | time:5.351048962s, loops:1666, rows:1704223 | N/A |
| └─IndexLookUp_22 | 1740137.10 | root | | time:5.472002572s, loops:1666, rows:1704223 | 34.88465213775635 MB |
| ├─IndexScan_19 | 2526725.00 | cop | table:dc_f_d_s, index:id, range:[NULL,+inf], keep order:true | proc max:1.96s, min:254ms, p80:1.96s, p95:1.96s, rows:2526563, iters:2481, tasks:3 | N/A |
| └─Selection_21 | 1740137.10 | cop | eq(pressure_pfizer.dc_f_d_s.is_Del, "0") | proc max:127ms, min:0s, p80:46ms, p95:65ms, rows:1704223, iters:10846, tasks:1880 | N/A |
| └─TableScan_20 | 2526725.00 | cop | table:dc_f_d_s, keep order:false | proc max:125ms, min:0s, p80:45ms, p95:65ms, rows:2526563, iters:10846, tasks:1880 | N/A |
+--------------------------------+------------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
9 rows in set (5.68 sec)
mysql>
【问题描述】:
单独执行SQL 时 SQL执行时间在 5秒左右,使用内存 33MB左右, 但是批量执行时,消耗的内存与消耗的时间都会变的很大,不知道为什么会这样