Tuesday, October 11, 2022

Is flushing shared pool and buffer cache is good?

Flushing shared pool and buffer cache is not recommended and we should not perform on PROD environment

Flush Shared pool meaning flushing cached execution plan and SQL Queries from memory.
Flush buffer cache meaning flushing cached data from memory.

Database restart which internally flush both shared pool and buffer cache.

Flushing the data buffer cache & Shared pool is not recommend on Production Environment.
It may lead to increase the performance overhead, especially on RAC databases.

Flush buffer cache may lead to disk I/0 overhead.

https://docs.oracle.com/database/121/ARPLS/d_result_cache.htm#ARPLS202

1. Before flushing shared pool and buffer cache 

[root@oraclelab1 ~]# su - oracle
Last login: Fri Aug 26 18:47:01 IST 2022 on pts/1
[oracle@oraclelab1 ~]$
[oracle@oraclelab1 ~]$ ps -ef|grep smon
oracle    4467     1  0 Aug09 ?        00:00:19 ora_smon_DEVDB
[oracle@oraclelab1 ~]$
[oracle@oraclelab1 ~]$ . oraenv
ORACLE_SID = [oracle] ? DEVDB
The Oracle base has been set to /u01/app/oracle
[oracle@oraclelab1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 27 01:56:44 2022
Version 19.14.0.0.0

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.14.0.0.0

SQL> select count(*) from v$sql;

  COUNT(*)
----------
      7049

SQL> exec dbms_result_cache.memory_report;

PL/SQL procedure successfully completed.

SQL> set serveroutput on;
SQL> exec dbms_result_cache.memory_report;
R e s u l t   C a c h e   M e m o r y   R e p o r t
[Parameters]
Block Size          = 1K bytes
Maximum Cache Size  = 18048K bytes (18048 blocks)
Maximum Result Size = 902K bytes (902 blocks)
[Memory]
Total Memory = 800200 bytes [0.085% of the Shared Pool]
... Fixed Memory = 12424 bytes [0.001% of the Shared Pool]
... Dynamic Memory = 787776 bytes [0.084% of the Shared Pool]
....... Overhead = 165184 bytes
....... Cache Memory = 608K bytes (608 blocks)
........... Unused Memory = 12 blocks
........... Used Memory = 596 blocks
............... Dependencies = 11 blocks (11 count)
............... Results = 585 blocks
................... SQL     = 3 blocks (3 count)
................... PLSQL   = 6 blocks (6 count)
................... Invalid = 576 blocks (576 count)

PL/SQL procedure successfully completed.

2. After flushing shared pool and buffer cache

SQL> startup force;
ORACLE instance started.

Total System Global Area 3690985848 bytes
Fixed Size                  8903032 bytes
Variable Size             989855744 bytes
Database Buffers         2684354560 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.
SQL> select count(*) from v$sql;

  COUNT(*)
----------
       445

SQL> set serveroutput on;
SQL> exec dbms_result_cache.memory_report;
R e s u l t   C a c h e   M e m o r y   R e p o r t
[Parameters]
Block Size          = 1K bytes
Maximum Cache Size  = 18048K bytes (18048 blocks)
Maximum Result Size = 902K bytes (902 blocks)
[Memory]
Total Memory = 202648 bytes [0.022% of the Shared Pool]
... Fixed Memory = 5848 bytes [0.001% of the Shared Pool]
... Dynamic Memory = 196800 bytes [0.021% of the Shared Pool]
....... Overhead = 164032 bytes
....... Cache Memory = 32K bytes (32 blocks)
........... Unused Memory = 25 blocks
........... Used Memory = 7 blocks
............... Dependencies = 5 blocks (5 count)
............... Results = 2 blocks
................... Invalid = 2 blocks (2 count)

PL/SQL procedure successfully completed.

SQL>

Manually flush buffer cache & shared pool cache without bouncing the database:
Standalone Database:
alter system flush buffer_cache;
alter system flush shared_pool;

RAC Database:
alter system flush buffer_cache global;
alter system flush shared_pool global;

Regards,
Mallik

No comments:

Post a Comment

Automation Script | Archivelog Generation Hourly Monitoring

1. List out all the running databases and pic one database where we want to monitore the archive log generation from last 1 month. [oracle@o...