postgres=# explain select * from gaotab where ctid='(0,10)';
QUERY PLAN
-------------------------------------------------------
Seq Scan on gaotab (cost=0.00..2.25 rows=1 width=17)
Filter: (ctid = '(0,10)'::tid)
(2 rows)
postgres=#
postgres=# explain select oid from pg_proc where ctid='(0,1)';
QUERY PLAN
-------------------------------------------------------
Tid Scan on pg_proc (cost=0.00..4.01 rows=1 width=4)
TID Cond: (ctid = '(0,1)'::tid)
(2 rows)
虽然据说涉及到 ctid 的时候, Tid Scan 因为物理上的原因,可能会很快。但是有的时候还是没有 sequential 来的快。
postgres=#
postgres=# explain select name from gaotab where ctid='(0,1)';
QUERY PLAN
------------------------------------------------------
Tid Scan on gaotab (cost=0.00..4.01 rows=1 width=5)
TID Cond: (ctid = '(0,1)'::tid)
(2 rows)
postgres=# set session enable_seqscan=true;
SET
postgres=# explain select name from gaotab where ctid='(0,1)';
QUERY PLAN
------------------------------------------------------
Seq Scan on gaotab (cost=0.00..2.25 rows=1 width=5)
Filter: (ctid = '(0,1)'::tid)
(2 rows)
postgres=#
[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com ]
结束