oracle如何做强制缓存

oracle如何做强制缓存,第1张

-- 加入缓存

SQL> ALTER TABLE a CACHE;

Table altered

-- 取消加入缓存

SQL> ALTER TABLE a NOCACHE;

Table altered

ALTER SYSTEM FLUSH SHARED_POOL

这个语句清除SGA中的 shared pool,shared pool存储下面的信息:

1、数据字典

2、Shared SQL & PL/SQL,存储过程、函数、包以及触发器

但是有一点要清楚的是假如这些对象正在使用时是无法清除的。

一、 空闲缓存块

当我们利用SELECT语句从数据库文件中读取文件的时候,数据库首先会寻找是否有空闲的缓存。

二、命中缓存块

当SELECT语句先从数据库文件中读取数据后,会把取得的数据放入到这个命中缓存块中。也就是说,当我们利用查询语句从数据库查询处员工信息后,这个信息就会被保存在高速缓存中

三、脏缓存块

1、为Oracle数据库配置尽量大的内存。Oracle数据库最新版本,根据官方的建议,其内存需要1G。虽然在低于这个内存数量的时候,数据库仍然可以运行,但是,其运行适度会大打折扣。当查询大量数据的时候,更是比较吃力。笔者现在使用的数据库服务器,是使用了4个G的内存。以前我用的是2个G的。内存升级后,发现数据库的性能得到了比较大的改善。

2、在对数据进行查询 *** 作时,尽量使用限制条件。如现在需要查询销售部门的员工信息时,我们不需要查询全部的员工信息,而是在SELECT语句中,利用WHERE条件语句设置查询条件。如此的话,就可以充分利用DIRTY列表中的空闲缓存块,而不会因为空闲缓存块容量不够而频繁的去执行数据库写 *** 作。这会明显降低数据库的运行 *** 作。同时,在查询时,最好也能够明确查询的信息,如你只需要员工的姓名与入职日期,那就不需要把员工的出生年月、身份z号码都查询出来。所以,有时候合理设计视图,也可以提高数据库的运行效率。

3、最好不要在数据库服务器上运行其他的服务。在数据库服务器中,若还运行其它服务器的话,除了硬件资源争夺影响服务器的运行效率之外,还会产生一个问题。就是会使得数据库的数据高速缓存块不连续。这会直接影响数据库查询空闲缓存块的效率。对脏缓存块进行数据库写入 *** 作以及数据库进行标记之间的转换也会产生影响。所以,根据笔者的经验,数据库服务器最好能够独立。最多只能跟其对应的应用服务器部署在同一台服务器上。如现在Oracle数据库是一台ERP系统的后台数据库,最好数据库能够跟ERP服务器分开部署。但是,若由于服务器资金的限制,那么可以把ERP应用服务器跟数据库服务器部署在一台服务器上。但是,不能再跟邮件服务器等应用服务器放在一起。这会影响数据高速缓存的管理效率,从而最终影响数据库的运行效能。现在服务器价格逐渐下滑,服务器的成本已经不是影响企业数据库应用的关键。所以,出于数据库性能考虑,笔者认为,企业在这上面还是应该大方的进行投资。没必要为了这么一点点钱,影响到数据库的性能。

四:如果表的数据很多的话,记得把表分区,消除表空间碎片,这样能提高查询的效率

五:创建存相应储过程或者触发器

希望能有所帮助

oracle的结果集缓存

oracle 调整结果集缓存,只有3个参数。

RESULT_CACHE_MAX_SIZE=500M / Megabytes

RESULT_CACHE_MAX_RESULT=20 / Percentage

RESULT_CACHE_REMOTE_EXPIRATION=3600 / Minutes

但是在 result_cache_mode 为force 的时候才会去保存所有的查询,在manual 的时候需要+HINT 来enable

alter session set result_cache_mode=force;

show parameter result_cache

NAME TYPE VALUE

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

client_result_cache_lag big integer 3000

client_result_cache_size big integer 0

result_cache_max_result integer 5

result_cache_max_size big integer 5984K

result_cache_mode string MANUAL

result_cache_remote_expiration integer 0

查询下内存分配情况

SQL> SET SERVEROUTPUT ON

SQL> execute dbms_result_cachememory_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 = 5984K bytes (5984 blocks)

Maximum Result Size = 299K bytes (299 blocks)

[Memory]

Total Memory = 174752 bytes [0027% of the Shared Pool]

Fixed Memory = 10696 bytes [0002% of the Shared Pool]

Dynamic Memory = 164056 bytes [0026% of the Shared Pool]

Overhead = 131288 bytes

Cache Memory = 32K bytes (32 blocks)

Unused Memory = 30 blocks

Used Memory = 2 blocks

Dependencies = 1 blocks (1 count)

Results = 1 blocks

SQL = 1 blocks (1 count)

PL/SQL procedure successfully completed

好像只有oracle 有这个东西,DB2 和mysql 都没有。

当Oracle数据库断电时,缓存日志将不会写回到物理路径。这可能会导致数据库中的一些数据丢失,因为在断电之前,缓存日志中的数据尚未写入到物理路径。为了避免这种情况,建议定期执行完整的备份,以便在发生意外情况时可以恢复数据库。

看看oracle官方的解释就知道了,这些英文也不是很难,应该不用我翻译了,个别不认识的单词用金山词霸翻译一下就可以了

A system global area (SGA)(系统全局区) is a group of shared memory structures that contain data and control information for one Oracle database instance(实例) If multiple users are concurrently connected to the same instance, then the data in the instance's SGA is shared among the users Consequently(因此), the SGA is sometimes called the shared global area(共享全局区)

An SGA and Oracle processes constitute(构成) an Oracle instance Oracle automatically allocates(分配) memory for an SGA when you start an instance, and the operating system reclaims(收回) the memory when you shut down the instance Each instance has its own SGA

The SGA is read/write All users connected to a multiple-process database instance can read information contained within the instance's SGA, and several processes write to the SGA during execution of Oracle

The SGA contains the following data structures:

Database buffer cache(数据高速缓冲区)

Redo log buffer(重做日志缓冲区)

Shared pool(共享池)

Java pool

Large pool (optional)

Streams pool

Data dictionary cache

Other miscellaneous information

Part of the SGA contains general information about the state of the database and the instance, which the background processes need to access; this is called the fixed SGA No user data is stored here The SGA also includes information communicated between processes, such as locking information

If the system uses shared server architecture, then the request and response queues and some contents of the PGA are in the SGA

以上就是关于oracle如何做强制缓存全部的内容,包括:oracle如何做强制缓存、Oracle如何清理多次select查询后在内存中的缓存数据、关于Oracle 的问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10186305.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-06
下一篇2023-05-06

发表评论

登录后才能评论

评论列表(0条)

    保存