Rank Causes Full Table Scan

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: rank 导致全表扫描

| username: 今天不想写代码

【TiDB Usage Environment】Production
【TiDB Version】6.5
【Encountered Issue: Problem Phenomenon and Impact】
Subquery followed by rank sorting causes a full table scan.

| username: tidb菜鸟一只 | Original post link

What is the execution plan for executing a subquery separately?

| username: 今天不想写代码 | Original post link

I can’t view images directly. Please provide the text you need translated.

| username: WalterWj | Original post link

If possible, you can export the replayer and share it: 使用 PLAN REPLAYER 保存和恢复集群现场信息 | PingCAP 文档中心

| username: onlyacat | Original post link

If possible, please provide the table structure.

| username: 今天不想写代码 | Original post link

We use a lot of aggregations in our business. After setting up TiFlash, it became faster.

| username: tidb菜鸟一只 | Original post link

You can collect some statistics on the table, then execute explain analyze to check. It seems that the SQL index above is incorrect.

| username: wangkk2024 | Original post link

Statistics

| username: xiaoqiao | Original post link

Check the statistics, table structure, and index selectivity.

| username: 友利奈绪 | Original post link

You can try modifying the binding to force it to use a specific index.

| username: 小龙虾爱大龙虾 | Original post link

Add a hint to handle it. The optimizer evaluates that the cost of using the index’s orderliness is lower.

| username: zhaokede | Original post link

Check if these fields in the query conditions are indexed.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.