Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle: flush the data buffer cache

Oracle Tips by Burleson Consulting
June 19, 2008

Question:  How can I flush the buffer cache in Oracle?  I'm doing testing and I don't want to have to bounce the database.  I'm on Oracle 10g release 2.

Answer:  When performing performance tests, it's important to replicate the real-world production environment as closely as possible, especially with regard to disk reads since they are a major time-consuming event.  Flushing the data buffer cache is a great testing tool, and save you from having to bounce (stop and re-start) your database instance between test runs.  We DO NOT recommend flushing your data buffer cache on a production system!

The opposite of flushing the data buffers is to use the KEEP pool to eliminate disk I/O, and do the performance test without disk reads.

In Oracle 9i and beyond you can flush the buffer cache with this command:

alter session set events ?immediate trace name flush_cache?;

In Oracle 10g and beyond, this command will flush the buffer cache:

alter system flush buffer_cache;

Note:  Flushing the data buffer cache imposes a serious performance overhead, especially on RAC databases.  Using the flush buffer cache was intended only for test system.

In Oracle you can also flush the shared pool, if needed.  See flushing the shared pool

In the past, we had a facility to flush the shared pool. The FLUSH SHARED POOL clause of ALTER SYSTEM lets you clear all data from the shared pool in the SGA (system global area). This is a useful feature to clear existing data and re-load fresh data. Now, with 10g, it becomes possible for users to flush the cache buffers also.

Before 10g, Oracle used to internally flush the buffer cache blocks as needed. The FLUSH SHAREDPOOL clause is useful if you need to measure the performance of rewritten queries or a suite of queries from identical starting points. Use the following statement to flush the buffer cache.

SQL> ALTER SYSTEM FLUSH BUFFER_CACHE;

System altered.

However, note that this clause is intended for use only on a test database. It is not advisable to use this clause on a production database, because subsequent queries will have no hits, only misses.

The following example shows the effect of flush buffer_cache. There are 50,000 rows in the table ?POLICYREC?.

SQL> update POLICYREC set sum_assured = sum_assured + 15;

50000 rows updated.

SQL> commit;

Commit complete.

SQL> select o.OBJECT_TYPE, substr(o.OBJECT_NAME,1,10)
  objname , b.objd , b.status, count(b.objd) from v$bh b,
  dba_objects o where b.objd = o.data_object_id and
  o.owner = 'NYUSER' group by o.object_type,
  o.object_name,b.objd, b.status ;

OBJECT_TYPE  OBJNAME         OBJD STATUS   COUNT(B.OBJD)

----------- -------------   ------ ------  -------

TABLE       TEST1             43058 free         6

TABLE       POLICYREC         43061 cr          47

TABLE       POLICYREC         43061 free       238

TABLE       POLICYREC         43061 xcur       376

 

SQL> alter system flush buffer_cache;

 

System altered.

 

SQL> select o.OBJECT_TYPE, substr(o.OBJECT_NAME,1,10)

 objname , b.objd , b.status, count(b.objd) from  v$bh b,

 dba_objects o where b.objd = o.data_object_id and

 o.owner = 'NYUSER' group by o.object_type,

 o.object_name,b.objd, b.status ;

 

 

OBJECT_TYPE OBJNAME       OBJD STATUS COUNT(B.OBJD)

---------- -------------- ----- ----- -------------

TABLE           TEST1      43058 free         6

TABLE       POLICYREC      43061 free       660

 


 

 

��  
 
 

 
 
 
 
oracle dba poster
 

 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2014

All rights reserved by Burleson

Oracle ? is the registered trademark of Oracle Corporation.