Does TiDB cache execution plans? If so, where are they cached?

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

Original topic: TiDB会缓存执行计划吗?如果缓存了缓存在哪里?

| username: alfred

[TiDB Usage Environment] Online, Testing, Research
[TiDB Version]
[Encountered Problem]
[Reproduction Path] What operations were performed to cause the problem
[Problem Phenomenon and Impact]

[Attachments]

Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.

| username: ddhe9527 | Original post link

Support caching execution plans for PREPARE/EXECUTE prepared statements; execution plans for regular SQL cannot be cached. The execution plans for prepared statements are cached in the memBuffer of the TiDB instance.

| username: forever | Original post link

The execution plan cache feature only applies to Prepare / Execute requests and is ineffective for regular queries. Plan Cache is at the SESSION level.

| username: alfred | Original post link

There are quite a few limitations.

| username: HACK | Original post link

From what I read in the documentation, the feature for prepared statement execution plan caching is available from version 5.4 onwards. Does this mean that version 4 does not support any execution plan caching?

| username: ddhe9527 | Original post link

Supported. In version 4.0, it is an experimental feature and is not enabled by default.

| username: system | Original post link

This topic will be automatically closed 60 days after the last reply. No new replies are allowed.