tgl=> explain select a from testg
NOTICE:QUERY
PLAN:
Seq Scan on test (cost=0.00 size=0 width=4)
EXPLAIN
tgl=> explain
verbose select sum(a) from test;
NOTICE:QUERY PLAN:
{AGG :cost 0 :size
0 :width 0 :state <> :qptargetlist
({TLE :resdom {RESDOM :resno 1 :restype
700 :restypmod 4 :resname "sum"
:reskey 0 :reskeyop 0 :resjunk 0}
:expr {AGGREG :aggname "sum" :basetype 700 :aggtype 700 :aggno 0
:target {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno
1}}})
:qpqual <> :lefttree {SEQSCAN :cost 0 :size 0 :width 4 :state <>
:qptargetlist ({TLE :resdom {RESDOM :resno 1 :restype 700 :restypmod
4
:resname "null" :reskey 0 :reskeyop 0 :resjunk 0}
:expr {VAR
:varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}})
:qpqual
<> :lefttree <> :righttree <> :scanrelid 1} :righttree <> :numagg 1 }
Aggregate
(cost=0.00 size=0 width=0)
-> Seq Scan on test (cost=0.00 size=0 width=4)
The Postgres optimizer has chosen to use a sequential scan to retrieve rows from this table. Indices will used by the optimizer after tables grow large enough to warrant the access overhead; typically this might happen when tables have a few hundred rows.
The query cost and plan can be affected by running vacuum.