Help Center> GaussDB> Centralized_3.x> SQL Optimization> Hint-based Tuning> Hint Specifying Not to Use Global Plan Cache
Updated on 2024-05-07 GMT+08:00

Hint Specifying Not to Use Global Plan Cache

Function

When global plan cache is enabled, you can use the no_gpc hint to force a single query statement not to share the plan cache globally. Only the plan cache within the current session lifecycle is retained.

Syntax

1
no_gpc

This parameter takes effect only for statements executed by PBE when enable_global_plancache is set to on.

Example

gaussdb=#  deallocate all;
DEALLOCATE ALL
gaussdb=#  prepare p1 as insert /*+ no_gpc*/ into t1 select c1,c2 from t2 where c1=$1;
PREPARE
gaussdb=#  execute p1(3);
INSERT 0 1
gaussdb=#  select * from dbe_perf.global_plancache_status where schema_name='public' order by 1,2;
 nodename | query | refcount | valid | databaseid | schema_name | params_num | func_id | pkg_id | stmt_id 
----------+-------+----------+-------+------------+-------------+------------+---------+--------+---------
(0 rows)

No result exists in the dbe_perf.global_plancache_status view, that is, no plan is cached globally.