| From: | buhhunyx(at)tut(dot)by |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: BUG #14750: Seq Scan instead of Index Scan works without limitation |
| Date: | 2017-07-20 07:40:40 |
| Message-ID: | 714641500536440@web1m.yandex.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Seq Scan is fine except its ignore PRIMARY KEY and UNIQUE CONSTRAINT: in case result is found it should be immediatly returned to avoid scan rest of data:
# explain analyze select accountid from accounts where accountname = 'accountId50';
Seq Scan on accounts (cost=0.00..2.50 rows=1 width=12) (actual time=0.018..0.029 rows=1 loops=1)
Filter: ((accountname)::text = 'accountId50'::text)
Rows Removed by Filter: 119
Planning time: 0.075 ms
Execution time: 0.048 ms
In product no 'LIMIT 1' specified because first found result expected; in case of huge amout simple queries difference is valuable:
# explain analyze select accountid from accounts where accountname = 'accountId50' limit 1;
Limit (cost=0.00..2.50 rows=1 width=12) (actual time=0.016..0.016 rows=1 loops=1)
-> Seq Scan on accounts (cost=0.00..2.50 rows=1 width=12) (actual time=0.014..0.014 rows=1 loops=1)
Filter: ((accountname)::text = 'accountId50'::text)
Rows Removed by Filter: 50
Planning time: 0.084 ms
Execution time: 0.035 ms
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2017-07-20 22:15:42 | Re: PgFDW connection invalidation by ALTER SERVER/ALTER USER MAPPING |
| Previous Message | Kyotaro HORIGUCHI | 2017-07-20 06:25:33 | Re: PgFDW connection invalidation by ALTER SERVER/ALTER USER MAPPING |