Orcle 12c 新特性---全库缓存

1 说明

顾名思义,全库缓存,就是将整个数据库放入到内存中,真刺激。当然,前提是内存大小要比整个数据库要大,而且要估算数据量的增长情况。这么一来,带来的性能肯定是巨大的,特别是对于I/O和响应时间提升非常明显。该特性会强行缓存所有表。

1.1 默认数据库缓存机制

  • Smaller tables are loaded into memory only when the table size is less than 2 percent of the buffer cache size.

小表,大小小于buffer cache的百分之二,会被加载到缓存中。

  • For medium tables, Oracle Database analyzes the interval between the last table scan and the aging timestamp of the buffer cache. If the size of the table reused in the last table scan is greater than the remaining buffer cache size, then the table is cached.
    对于中表,Oracle数据库分析了最后一个表扫描和buffer cache的老化时间戳之间的间隔。如果最后一个表扫描中重新用的表的大小大于剩余的缓冲区缓存大小,那么将缓存表。

  • Large tables are typically not loaded into memory, unless if you explicitly declare the table for the KEEP buffer pool.

对于大表,默认情况是不会缓存到缓存中的。除非你显示的KEEP。

注意:这种情况下,Oracle是不会缓存NOCACHE的LOB对象。

1.2 强行全库缓存

在强制完全数据库缓存模式下,当数据库的大小小于数据库缓冲区缓存大小时,Oracle数据库将缓存整个数据库。

所有被访问的数据文件(包括使用SecureFiles的NOCACHE lob和lob)都被加载到缓冲区缓存中。

1.2.1 什么时候使用全库缓存

Oracle建议:

  • The logical database size (or actual used space) is smaller than the individual buffer cache of each database instance in an Oracle RAC environment. This is applicable for non-Oracle RAC database as well.

  • The logical database size is smaller than 80% of the combined buffer cache sizes of all the database instances for well-partitioned workloads (by instance access) in an Oracle RAC environment.

    扫描二维码关注公众号,回复: 6554974 查看本文章
  • The database uses SGA_TARGET or MEMORY_TARGET.

  • The NOCACHE LOBs need to be cached. The NOCACHE LOBs are never cached unless force full database caching is used.

注意:

  1. 对于RAC缓解,如果其中一个节点是强行全库缓存,那么其他所有节点也会进行全库缓存。
  2. 对于CDB环境,缓存全库,包括该CDB上的所有PDB。

2 具体操作

由于没有环境能进行这样的操作,这里只举例子。

2.1 查看当前数据库是否是强行全库缓存

SQL> SELECT FORCE_FULL_DB_CACHING FROM V$DATABASE;

FORCE_
------
NO

2.2 启用强行全库缓存
—MOUNT状态下执行:

ALTER DATABASE FORCE FULL DATABASE CACHING;

2.3 禁用强行全库缓存
—MOUNT状态下执行:

ALTER DATABASE NO FORCE FULL DATABASE CACHING;

猜你喜欢

转载自blog.csdn.net/qianglei6077/article/details/92980247