Re: BUG #14750: Seq Scan instead of Index Scan works without limitation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: buhhunyx(at)tut(dot)by
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14750: Seq Scan instead of Index Scan works without limitation
Date: 2017-07-19 14:21:20
Message-ID: 7335.1500474080@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

buhhunyx(at)tut(dot)by writes:
> 1) Create initial structure [1].

> 2) explain analyze SELECT * FROM accounts WHERE accountid = 'accountId50';

> Index Scan using accounts_pkey on accounts (cost=0.15..8.17 rows=1
> width=272) (actual time=0.022..0.022 rows=1 loops=1)
> Index Cond: ((accountid)::text = 'accountId50'::text)
> Planning time: 0.201 ms
> Execution time: 0.045 ms

> 3) reindex table ACCOUNTS;

> 4) explain analyze SELECT * FROM accounts WHERE accountid = 'accountId50';

> Seq Scan on accounts (cost=0.00..2.50 rows=1 width=142) (actual
> time=0.024..0.037 rows=1 loops=1)
> Filter: ((accountid)::text = 'accountId50'::text)
> Rows Removed by Filter: 119
> Planning time: 0.095 ms
> Execution time: 0.060 ms

I see no bug here. The REINDEX caused the system's stats about the table
size to get updated, so the planner now realizes that the table is not
large enough to be worth bothering with an indexscan.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message dilaz03 2017-07-19 15:20:38 BUG #14753: Bad selectivity estimation with functional partial index
Previous Message johncarlo.butil 2017-07-19 13:29:33 BUG #14752: Cannot re-install Postgres after uninstall