Basic Oracle management: alter system flush "oracle cache"

Source: Internet
Author: User

The following three statements are used to refresh the Oracle cache. Here is a summary.

1)Alter system flush global context

Note:

For multi-tier architectures such as application servers and data block servers that communicate through the connection pool, the information about the connection pool is kept in SGA. This statement clears the connection information.

2)Alter system flush shared_pool

Make the library cache and data dictionary cachePreviousAll saved SQL Execution plans are cleared, but the recently executed entries cached in the shared SQL area or pl/SQL area are not cleared. Refreshing the shared pool can helpMerge shards(Small chunks) to release a few shared pool resources and temporarily solve the shared_pool fragmentation problem. However, this approach is generally not recommended. The reason is as follows:

· Flush Shared Pool will cause unused cursor to be cleared out of the Shared Pool. If these SQL statements need to be executed subsequently, the database will experience a lot of hard parsing, the system will experience severe CPU contention, and the database will have fierce Latch competition.
· If the application does not use Bound variables and a large number of similar SQL statements are not executed, the Flush Shared Pool may only provide a short improvement and the database will return to the original state soon.
· If the Shared Pool is large and the system is very busy, refreshing the Shared Pool may cause the system to be suspended. For systems like this, try to do it when the system is idle.

The following tests the effect of refreshing on Shared Pool fragments:

  1. SQL>Select Count(*)FromX $ ksmsp;
  2. COUNT(*)
  3. ----------
  4. 41637
  5. SQL>AlterSystem flush shared_pool;
  6. The system has been changed.
  7. SQL>Select Count(*)FromX $ ksmsp;
  8. COUNT(*)
  9. ----------
  10. 9276
3)Alter system flush buffer_cache

To minimize the impact of the cache on the test experiment, you need to manually refresh the buffer cache to urge oracle to re-Execute physical access (in statistics:Physical reads).

Test Environment

  1. SQL>Select Count(*)FromTt;
  2. COUNT(*)
  3. ----------
  4. 1614112
  5. SQL> showUser;
  6. USERIs"HR"
  7. SQL>ExecDbms_stats.gather_table_stats ('Hr','TT');
  8. The PL/SQL process is successfully completed.
  9. SQL>SelectBlocks, empty_blocksFromDba_tablesWhereTable_name ='TT' AndOwner ='Hr';
  10. BLOCKS EMPTY_BLOCKS
  11. ----------------------
  12. 22357 0
  13. Table TT has a total of 22357 Blocks

Observe the state = 0 with x $ bh

  1. SQL>Select Count(*)FromX $ bhWhereState = 0;
  2. COUNT(*)
  3. ----------
  4. 0
  5. SQL>AlterSystem flush buffer_cache;
  6. The system has been changed.
  7. SQL>Select Count(*)FromX $ bhWhereState = 0;
  8. COUNT(*)
  9. ----------
  10. 40440
State = 0 indicates that the buffer state is free. After the cache is flush, all the buffers are marked as free.

Observe the impact of flush cache on queries:

  1. SQL>SetAutotOn Statistics
  2. SQL>Select Count(*)FromTt;
  3. COUNT(*)
  4. ----------
  5. 1614112
  6. Statistics
  7. ----------------------------------------------------------
  8. 0 recursive cballs
  9. 0 db block gets
  10. 22288 consistent gets
  11. 22277 physical reads
  12. 0 redoSize
  13. 416 bytes sent via SQL * NetToClient
  14. 385 bytes encoded ed via SQL * NetFromClient
  15. 2 SQL * Net roundtripsTo/FromClient
  16. 0 sorts (memory)
  17. 0 sorts (disk)
  18. 1RowsProcessed
  19. SQL>/
  20. COUNT(*)
  21. ----------
  22. 1614112
  23. Statistics
  24. ----------------------------------------------------------
  25. 0 recursive cballs
  26. 0 db block gets
  27. 22288 consistent gets
  28. 0 physical reads
  29. 0 redoSize
  30. 416 bytes sent via SQL * NetToClient
  31. 385 bytes encoded ed via SQL * NetFromClient
  32. 2 SQL * Net roundtripsTo/FromClient
  33. 0 sorts (memory)
  34. 0 sorts (disk)
  35. 1RowsProcessed
  36. SQL>AlterSystem flush buffer_cache;
  37. The system has been changed.
  38. SQL>Select Count(*)FromTt;
  39. COUNT(*)
  40. ----------
  41. 1614112
  42. Statistics
  43. ----------------------------------------------------------
  44. 0 recursive cballs
  45. 0 db block gets
  46. 22288 consistent gets
  47. 22277 physical reads
  48. 0 redoSize
  49. 416 bytes sent via SQL * NetToClient
  50. 385 bytes encoded ed via SQL * NetFromClient
  51. 2 SQL * Net roundtripsTo/FromClient
  52. 0 sorts (memory)
  53. 0 sorts (disk)
  54. 1RowsProcessed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.