Result Cache¶
名称¶
结果集物化算子
介绍¶
如果数据库在表(或其他对象)上几乎不进行delete、update、insert等DML操作,而频繁的进行查询操作,可使用 /*+ result_cache*/ 对表的结果进行缓存,提高I/O效率。
举例¶
--清理环境
DROP TABLE t1 CASCADE;
--创建环境
CREATE TABLE t1(a_id int, a date);
INSERT INTO t1 VALUES(1,'2005-1-1');
INSERT INTO t1 VALUES(2,'2006-1-1');
INSERT INTO t1 VALUES(3,null);
INSERT INTO t1 VALUES(4,'2007-1-1');
ANALYZE t1;
EXPLAIN ANALYZE SELECT /*+ result_cache*/ * FROM t1;
QUERY PLAN
--------------------------------------------------------------------------------------------------
Result Cache (cost=7.04..7.04 rows=4 width=12) (actual time=0.02..0.03 rows=4 loops=1)
-> Seq Scan on T1 (cost=0.00..7.04 rows=4 width=12) (actual time=0.01..0.02 rows=4 loops=1)
Planning Time: 0.31 msec
Execution Time: 0.10 msec
(4 rows)