---
title: 如何确定 Plan Cache 的淘汰机制是否正常-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于 如何确定 Plan Cache 的淘汰机制是否正常相关的常见问题和使用技巧，帮助您快速解决 如何确定 Plan Cache 的淘汰机制是否正常的难题。
---
切换语言

- 简体中文
- English

划线反馈

# 如何确定 Plan Cache 的淘汰机制是否正常

更新时间：2026-05-08 08:11

适用版本： V2.1.x、V2.2.x、V3.1.x、V3.2.x 内容类型：How-to  

当 Plan Cache 内存不足时，即出现 `plan cache memory used reach limit` 告警，我们需要判断当前 Plan Cache 的内存使用状况以及淘汰机制是否正常。

OBServer 会在 Plan Cache 进行淘汰（evict）时记录日志信息到 `observer.log` 中，我们可以从日志中查看相关信息来判断当前 Plan Cache 的内存使用状况和淘汰机制的运行情况。

示例如下。

1. 使用租户 ID（格式为 `tenant_id=1009`）和关键字 `plan cache evict info` 搜索日志。

   ```shell
   [2023-09-03 01:41:11.715207] INFO  [SQL.PC] ob_plan_cache.cpp:1217 [2972130][732][Y0-0000000000000000] [lt=11] [dc=0] plan cache evict info(tenant_id=1009, mem_hold=19327352832, mem_limit=19327352830, plan_num=113162, pcv_set_num=225067)

   ```

   该日志显示了 Plan Cache 触发淘汰时的内存使用状况 `mem_hold=19327352832 > mem_limit=19327352830`，即内存用满了。
 2. 查看紧随其后的日志中包含 `actual evict number` 或 `EVICT INFO` 的日志记录。

   ```shell
   [2023-09-03 01:41:11.800506] INFO  [SQL.PC] ob_plan_cache.cpp:1448 [2972130][732][Y0-0000000000000000] [lt=10] [dc=0] actual evict number(evict_value_num=0)
   [2023-09-03 01:41:12.835802] INFO  [SQL.PC] ob_plan_cache.cpp:1448 [2972130][732][Y0-0000000000000000] [lt=17] [dc=0] actual evict number(evict_value_num=112533)
   [2023-09-03 01:41:13.165922] INFO  [SQL.PC] ob_plan_cache.cpp:1230 [2972130][732][Y0-0000000000000000] [lt=29] [dc=0] EVICT INFO(to_evict.count()=112533)

   ```

   `actual evict number` 表示当前淘汰的日志量，如果与 EVICT INFO 中的数量相同，说明淘汰正常进行。

   #### 注意

   由于 `actual evict number` 日志和 `EVICT INFO` 并没有 tenant_id 打印，需要注意避免因日志限流导致日志串行或者日志不准确的情况，正常情况下，每一个租户 ID 都应该有这些日志输出，如果缺失，可能存在日志限流导致无法准确判断问题。

## 适用版本

OceanBase 数据库 V2.x 和 V3.x 版本。

Previous

[如何手工 Flush KV Cache](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000209952)

Next

[Plan Cache 内存用满](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000209934) ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
