Result

名称

结果算子

介绍

当查询不需要从表中检索数据时,使用Result算子,比如NOW函数,INSERT INTO语句等

当查询语句的WHERE子句的判断结果不依赖表中数据时,使用Result算子进行返回

举例

EXPLAIN ANALYZE SELECT NOW();
                                    QUERY PLAN
----------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.52..0.52 rows=1 loops=1)
 Planning Time: 0.03 msec
 Execution Time: 0.05 msec
(3 rows)

--清理环境
DROP TABLE t1 CASCADE;

--创建环境
CREATE TABLE t1(a int);
ANALYZE t1;

EXPLAIN ANALYZE INSERT INTO t1 VALUES(1);
                                    QUERY PLAN
----------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.00..0.00 rows=1 loops=1)
 Planning Time: 0.03 msec
 Execution Time: 0.42 msec
(3 rows)

EXPLAIN ANALYZE SELECT * FROM t1 WHERE 1<>1;
                                      QUERY PLAN
--------------------------------------------------------------------------------------
 Result  (cost=0.00..89.92 rows=8192 width=4) (actual time=0.00..0.00 rows=0 loops=1)
   One-Time Filter: FALSE
   ->  Seq Scan on T1  (cost=0.00..89.92 rows=8192 width=4) (never executed)
 Planning Time: 0.13 msec
 Execution Time: 0.06 msec
(5 rows)
  • One-Time Filter 限定条件