【 TiDB 使用环境】
【概述】 场景 + 问题概述
同样的两条sql,查了一张分区表,有分页和排序操作,一条sql:select * from laiye_3rd_info.tbl_checkin_followers_partion where follower_id = 23129203 and event_id = 1 and stop = 0 and id > 0 order by id limit 2001;
执行结果如下:
另一条sql:select * from laiye_3rd_info.tbl_checkin_followers_partion where follower_id = 20775243 and event_id = 1 and stop = 0 and id > 0 order by id limit 2001;
执行计划如下:
[图片太宽没法截完整的图,见谅]
三个问题:
1、两条sql查到的结果都是几十条,为啥sql1里的TopN下还套着一个TopN
2、sql1里其他分区都是TopN,为啥有一个分区是Limit(主要耗时)
3、sql1里estRows和actRows相差太大是怎么回事
【背景】 做过哪些操作
【现象】 业务和数据库现象
【问题】 当前遇到的问题
【业务影响】
业务查询慢
【TiDB 版本】
v4.0.14
【应用软件及版本】
【附件】 相关日志及配置信息
- TiUP Cluster Display 信息
- TiUP CLuster Edit config 信息
监控(https://metricstool.pingcap.com/)
- TiDB-Overview Grafana监控
- TiDB Grafana 监控
- TiKV Grafana 监控
- PD Grafana 监控
- 对应模块日志(包含问题前后 1 小时日志)