别名使用

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
postgres=# create table hint_t6(f1 integer,f2 integer) ;
CREATE TABLE
postgres=# insert into hint_t6 select t as f1,t as f2 from generate_series(1,10000) as t; 
INSERT 0 10000
postgres=# create index hint_t6_f1_idx on hint_t6(f1);      
CREATE INDEX
postgres=# vacuum ANALYZE hint_t6;
VACUUM
postgres=# select /*+full(hint_t6) */ * from hint_t6 a where f1=1;
 f1 | f2 
----+----
  1 |  1
(1 row) 
postgres=# explain select /*+full(hint_t6) */ * from hint_t6 a where f1=1;;
                                      QUERY PLAN                                      
--------------------------------------------------------------------------------------
 Remote Subquery Scan on all (dn001)  (cost=0.16..4.18 rows=1 width=8)
   ->  Index Scan using hint_t6_f1_idx on hint_t6 a  (cost=0.16..4.18 rows=1 width=8)
         Index Cond: (f1 = 1)
(3 rows) 
postgres=# explain select /*+full(a) */ * from hint_t6 a where f1=1;  
                               QUERY PLAN                                
-------------------------------------------------------------------------
 Remote Subquery Scan on all (dn001)  (cost=0.00..200.00 rows=1 width=8)
   ->  Seq Scan on hint_t6 a  (cost=0.00..200.00 rows=1 width=8)
         Filter: (f1 = 1)
(3 rows)