Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXpqw-00013j-DY for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Jul 2017 14:21:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dXpqv-0008D3-QF for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Jul 2017 14:21:25 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dXpqv-0008Cq-CM for pgsql-bugs@postgresql.org; Wed, 19 Jul 2017 14:21:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dXpqs-0008Dy-I7 for pgsql-bugs@postgresql.org; Wed, 19 Jul 2017 14:21:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v6JELK6s007336; Wed, 19 Jul 2017 10:21:21 -0400 From: Tom Lane To: buhhunyx@tut.by cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14750: Seq Scan instead of Index Scan works without limitation In-reply-to: <20170719114246.19352.23577@wrigleys.postgresql.org> References: <20170719114246.19352.23577@wrigleys.postgresql.org> Comments: In-reply-to buhhunyx@tut.by message dated "Wed, 19 Jul 2017 11:42:46 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7334.1500474080.1@sss.pgh.pa.us> Date: Wed, 19 Jul 2017 10:21:20 -0400 Message-ID: <7335.1500474080@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org buhhunyx@tut.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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs