首批通过分布式安全可靠测评,为关键业务系统打造
远程执行的 SQL 在 PLAN CACHE 中有 2 个执行计划
更新时间:2026-05-14 09:21
OceanBase 数据库执行一条远程 SQL 语句,会在 PLAN CACHE 中保留的执行计划个数。
适用版本
OceanBase 数据库 V2.x 和 V3.x 版本。
问题分析
这样的 SQL 语句执行后,会在 PLAN CACHE 中保留两个执行计划。
- Leader 节点(实际 SQL 的执行节点)会有一个计划。
- 会话节点(会话连接的节点,会通过 RPC 将 SQL 发往 Leader 节点执行)会有一个计划。
可以根据根据对应 sql_id 来检索 PLAN CACHE 确认:如下结果中,192.xxx.x.111 为 Leader 所在节点,192.xxx.x.112 为会话连接节点。
MySQL [test]> select * from oceanbase.__all_virtual_plan_stat where sql_id='9D49646606E7E50004B91A943172860F'\G
*************************** 1. row ***************************
tenant_id: 1
svr_ip: 192.xxx.x.112
svr_port: 2882
plan_id: 10892824
sql_id: 9D49646606E7E50004B91A943172860F
type: 2
is_bind_sensitive: 0
is_bind_aware: 0
statement: select * from test.alitestabc limit 1
query_sql: select * from test.alitestabc limit 1
special_params: 1
param_infos:
sys_vars: 45,45,12582912,2,4,1,0,0,32,3,1,0,1,1,0,10485760,1,1,0,1,BINARY,BINARY,AL32UTF8,AL16UTF16,BYTE,FALSE,1,100,64,200,0,13,NULL,1,1,1,1
plan_hash: 6793023352788177816
first_load_time: 2023-04-10 17:39:04.594569
schema_version: 1681118309502464
merged_version: 22
last_active_time: 2023-04-10 17:39:04.596277
avg_exe_usec: 26164
slowest_exe_time: 2023-04-10 17:39:04.596277
slowest_exe_usec: 26164
slow_count: 0
hit_count: 0
plan_size: 41024
executions: 1
disk_reads: 0
direct_writes: 0
buffer_gets: 0
application_wait_time: 0
concurrency_wait_time: 0
user_io_wait_time: 0
rows_processed: 1
elapsed_time: 26164
cpu_time: 16083
large_querys: 0
delayed_large_querys: 0
outline_version: 0
outline_id: -1
outline_data: /*+ BEGIN_OUTLINE_DATA FULL(@"SEL$1" "test.alitestabc"@"SEL$1") END_OUTLINE_DATA*/
acs_sel_info:
table_scan: 1
db_id: 1099511627785
evolution: 0
evo_executions: 0
evo_cpu_time: 0
timeout_count: 0
ps_stmt_id: -1
delayed_px_querys: 0
sessid: 0
temp_tables:
is_use_jit: 0
object_type: SQL_PLAN
enable_bf_cache: 1
bf_filter_cnt: 0
bf_access_cnt: 0
enable_row_cache: 1
row_cache_hit_cnt: 0
row_cache_miss_cnt: 0
enable_fuse_row_cache: 1
fuse_row_cache_hit_cnt: 0
fuse_row_cache_miss_cnt: 0
hints_info:
hints_all_worked: 1
pl_schema_id: 0
is_batched_multi_stmt: 0
is_in_pc: 1
erase_time: 0000-00-00 03:59:05.224191
*************************** 2. row ***************************
tenant_id: 1
svr_ip: 192.xxx.x.111
svr_port: 2882
plan_id: 7146772
sql_id: 9D49646606E7E50004B91A943172860F
type: 1
is_bind_sensitive: 0
is_bind_aware: 0
statement: select * from test.alitestabc limit 1
query_sql: select * from test.alitestabc limit 1
special_params:
param_infos:
sys_vars: 45,45,12582912,2,4,1,0,0,32,3,1,0,1,1,0,10485760,1,1,0,1,BINARY,BINARY,AL32UTF8,AL16UTF16,BYTE,FALSE,1,100,64,200,0,13,NULL,1,1,1,1
plan_hash: 1231240488336332984
first_load_time: 2023-04-10 17:39:04.596017
schema_version: 1681118309502464
merged_version: 22
last_active_time: 2023-04-10 17:39:04.596122
avg_exe_usec: 1387
slowest_exe_time: 2023-04-10 17:39:04.596122
slowest_exe_usec: 1387
slow_count: 0
hit_count: 0
plan_size: 41024
executions: 1
disk_reads: 0
direct_writes: 0
buffer_gets: 0
application_wait_time: 0
concurrency_wait_time: 0
user_io_wait_time: 0
rows_processed: 0
elapsed_time: 1387
cpu_time: 1355
large_querys: 0
delayed_large_querys: 0
outline_version: 0
outline_id: -1
outline_data: /*+ BEGIN_OUTLINE_DATA FULL(@"SEL$1" "test.alitestabc"@"SEL$1") END_OUTLINE_DATA*/
acs_sel_info:
table_scan: 1
db_id: 18446744073709551615
evolution: 0
evo_executions: 0
evo_cpu_time: 0
timeout_count: 0
ps_stmt_id: 0
delayed_px_querys: 0
sessid: 0
temp_tables:
is_use_jit: 0
object_type: SQL_PLAN
enable_bf_cache: 1
bf_filter_cnt: 0
bf_access_cnt: 0
enable_row_cache: 1
row_cache_hit_cnt: 0
row_cache_miss_cnt: 0
enable_fuse_row_cache: 1
fuse_row_cache_hit_cnt: 0
fuse_row_cache_miss_cnt: 0
hints_info:
hints_all_worked: 1
pl_schema_id: 0
is_batched_multi_stmt: 0
is_in_pc: 1