Seq Scan is fine except its ignore PRIMARY KEY and UNIQUE CONSTRAINT: in case result is found it should be immediatly
returnedto avoid scan rest of data:
# explain analyze select accountid from accounts where accountname = 'accountId50';Seq Scan on accounts
(cost=0.00..2.50rows=1 width=12) (actual time=0.018..0.029 rows=1 loops=1) Filter: ((accountname)::text =
'accountId50'::text) Rows Removed by Filter: 119Planning time: 0.075 msExecution time: 0.048 ms
In product no 'LIMIT 1' specified because first found result expected; in case of huge amout simple queries difference
isvaluable:
# explain analyze select accountid from accounts where accountname = 'accountId50' limit 1;Limit (cost=0.00..2.50
rows=1width=12) (actual time=0.016..0.016 rows=1 loops=1) -> Seq Scan on accounts (cost=0.00..2.50 rows=1 width=12)
(actualtime=0.014..0.014 rows=1 loops=1) Filter: ((accountname)::text = 'accountId50'::text) Rows Removed
byFilter: 50Planning time: 0.084 msExecution time: 0.035 ms
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs