使用这样的sql语句查询对主键排序特别慢,这是为什么呢,有什么解决办法吗
select * from alarm_log order by ts desc limit 0,10;
贡献者指南
技术栈
csql
领域
databaseperformance
议题类型
performance
难度面向新贡献者的预计实现难度,1 表示很小改动,5 表示专家级工作。
3
预计时间有经验贡献者完成调查、实现、测试并准备 pull request 的粗略时间范围。
1-3 hours
活动状态议题当前的可参与程度:新鲜、活跃、陈旧、阻塞或等待维护者输入。
fresh
清晰度议题是否清楚说明期望改动、验收标准和下一步。
needs investigation
前置要求
Basic understanding of TDengineSQL query optimization concepts
新手友好度1-100 的估计分数,表示该议题对首次贡献者的友好程度。
20
研究方向
The issue lacks schema details (e.g., number of columns, data volume), query execution plan, and whether the super table's primary key is properly indexed. First, check if the user has provided a reproducible test case in the comments. Look at the query execution path in TSDB: examine the order by implementation in the source code (likely in `tsdb/` directory). Verify if the query uses the primary key index or performs a full scan. Search for similar reported issues in the repository. If possible, replicate the slow query with a simple schema and measure performance with and without order by. Provide guidance on using EXPLAIN to get query plan.