From: buhhunyx@tut.by
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14750: Seq Scan instead of Index Scan works without limitation
Date: Thu, 20 Jul 2017 10:40:40 +0300
Message-ID: <714641500536440@web1m.yandex.ru> (raw)
In-Reply-To: <7335.1500474080@sss.pgh.pa.us>
References: <20170719114246.19352.23577@wrigleys.postgresql.org>
<7335.1500474080@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: buhhunyx@tut.by, tgl@sss.pgh.pa.us
Subject: Re: BUG #14750: Seq Scan instead of Index Scan works without limitation
In-Reply-To: <714641500536440@web1m.yandex.ru>
References: <20170719114246.19352.23577@wrigleys.postgresql.org> <7335.1500474080@sss.pgh.pa.us> <714641500536440@web1m.yandex.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox