How to Use Optimizer Tracing

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

Original topic: 如何使用Optimizer Tracing

| username: TiDBer_888

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 6.2
[Encountered Problem: Problem Phenomenon and Impact]
I saw a request for the Optimizer Tracing feature. Does TiDB currently support it? If it does, how can I use it? I don’t seem to find any related documentation.

| username: db_user | Original post link

This should suffice: TRACE | PingCAP 文档中心

| username: h5n1 | Original post link

Try using EXPLAIN FORMAT='cost_trace' to see if it can execute.

| username: TiDBer_888 | Original post link

It seems that the release-6.2 version on my local machine is still not working, but thanks, I will try other versions.

| username: TiDBer_888 | Original post link

You are tracking the execution process. I need to track the optimizer’s optimization process, such as the selection of multiple access paths, and it needs to be printed out.

| username: TiDBer_888 | Original post link

I directly modified the source code and hardcoded EnableOptimizeTrace to true. Then, during debugging, I checked the variables in the following method…

// RecordFinalPlanTrace records final physical plan trace
func (tracer *PhysicalOptimizeTracer) RecordFinalPlanTrace(root *PlanTrace) {
    tracer.Final = toFlattenPlanTrace(root)
    tracer.buildCandidatesInfo()
}

However, it seems that TiDB’s Optimize Trace feature shows much less information compared to MySQL, and feels relatively weak. I’m not sure if I’m using it incorrectly?

| username: system | Original post link

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