pingcap / pingcap/tidb

Add a framework for disabling plans during optimization.

Open
#65,895 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

Problem

There is no universal way to disable the plan cache for a query during optimization. The two existing methods have limitations:
1. `SetSkipPlanCache` disables the plan cache preemptively, even if the problematic plan is not ultimately selected.
2. `isPhysicalPlanCacheable` walks the final plan to check cacheability, but not all conditions can be discovered at this stage since context from earlier optimization phases (e.g., access path selection) may be lost.

Enhancement

Add support to both base.Plan and util.AccessPath to track whether a plan can be cached along with the reason. This allows:
• Marking paths as non-cacheable early during path generation
• Propagating the non-cacheable reason through plan construction
• Checking the reason during plan cache validation without needing type-specific logic

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.