Purpose
You can use this statement to clear the cache of a specified database.
Syntax
alter_system_flush_stmt:
ALTER SYSTEM flush_action;
flush_action:
FLUSH LOCATION CACHE [TENANT [=] tenant_list]
| FLUSH KVCACHE [TENANT [=] tenant_name] [CACHE [=] cache_name]
| FLUSH PLAN CACHE [ [SQL_identifier] [database_list] tenant_name_list ] [GLOBAL]
tenant_list:
tenant_name,tenant_name ...
database_list:
databases ='database_name, database_name...'
tenant_name_list:
TENANT = 'tenant_name, tenant_name....'
Parameters
| Parameter | Purpose |
|---|---|
| FLUSH LOCATION CACHE | Clears the location cache. |
| FLUSH KVCACHE | Clears auto-scaling memory (KVCache).
|
| FLUSH PLAN CACHE | Clears the plan cache for specified databases and SQL statements. |
| SQL_identifier | The SQL statement in the format of sql_id = 'xxx'. If you do not specify this parameter, all SQL plan caches are cleared. |
| database_list | The databases. If you do not specify this parameter, all plan caches are cleared. |
| tenant_list | The tenants. Be sure to specify tenant_list when specifying SQL_identifier and database_list to limit the operation to specified tenants. Note: Only the sys tenant can specify tenant_list. Other tenants cannot specify this parameter, meaning that they can only clear their own plan caches. If the sys tenant does not specify tenant_list, the plan caches of all tenants are cleared. |
| Global | Optional. If you do not specify this parameter, plan caches of the specified server are cleared. Otherwise, plan caches of all servers associated to the tenant are cleared. |
Examples
Clear the location cache
obclient> ALTER SYSTEM FLUSH LOCATION CACHE; Query OK, 0 rows affectedClear all KVCaches
obclient> ALTER SYSTEM FLUSH KVCACHE; Query OK, 0 rows affectedClear the KVCache for MySQL tenants
obclient> ALTER SYSTEM FLUSH KVCACHE TENANT 'MySQL'; Query OK, 0 rows affectedClear the plan cache for all tenants
obclient> ALTER SYSTEM FLUSH PLAN CACHE; Query OK, 0 rows affectedClear the plan cache for MySQL tenants and Oracle tenants
obclient> ALTER SYSTEM FLUSH PLAN CACHE TENANT = 'MySQL','Oracle'; Query OK, 0 rows affectedClear the specified plan cache in the sys tenant
obclient> ALTER SYSTEM FLUSH PLAN CACHE sql_id='B601070DFC14CB85FDA3766A69A9E1B3' databases='myob1' tenant='tenant1' GLOBAL; Query OK, 0 rows affectedClear the plan cache of a user tenant that has logged on as the DBA
obclient> ALTER SYSTEM FLUSH PLAN CACHE sql_id='B601070DFC14CB85FDA3766A69A9E1B3' databases='myob1' GLOBAL; Query OK, 0 rows affected