Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNyHw-0004ky-1i for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Mar 2014 05:34:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WNyHv-0006tk-D7 for pgsql-bugs@arkaria.postgresql.org; Thu, 13 Mar 2014 05:34:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNyHt-0006tb-Dh for pgsql-bugs@postgresql.org; Thu, 13 Mar 2014 05:34:37 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNyHq-0001Gv-62 for pgsql-bugs@postgresql.org; Thu, 13 Mar 2014 05:34:36 +0000 Received: from mfs5.rdh.ecl.ntt.co.jp (mfs5.rdh.ecl.ntt.co.jp [129.60.39.144]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id s2D5YQo3015502; Thu, 13 Mar 2014 14:34:26 +0900 Received: from mfs5.rdh.ecl.ntt.co.jp (localhost.localdomain [127.0.0.1]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id B351FE013E; Thu, 13 Mar 2014 14:34:26 +0900 (JST) Received: from imail3.m.ecl.ntt.co.jp (imail3.m.ecl.ntt.co.jp [129.60.5.248]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 9E3E4E013D; Thu, 13 Mar 2014 14:34:26 +0900 (JST) Received: from localhost ([129.60.241.55]) by imail3.m.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id s2D5YQms002592; Thu, 13 Mar 2014 14:34:26 +0900 Date: Thu, 13 Mar 2014 14:34:26 +0900 (Tokyo Standard Time) Message-Id: <20140313.143426.16396458.horiguchi.kyotaro@lab.ntt.co.jp> To: digoal@126.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9552: IndexOnlyScan startup_cost>0, why not equal 0?it's a bug? From: Kyotaro HORIGUCHI In-Reply-To: <20140313005429.398.2021@wrigleys.postgresql.org> References: <20140313005429.398.2021@wrigleys.postgresql.org> User-Agent: Mew version 6.5 on Emacs 22.2 / Mule 5.0 =?iso-2022-jp?B?KBskQjpnGyhCKQ==?= / Meadow-3.01-dev (TSUBO-SUMIRE) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Pg-Spam-Score: -1.9 (-) 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 Hello, > I belive index only scan can return tuple direct, it's not need to scan > heappage, why it's startup_cost equal to index scan? > I'ts a bug? No. It is a result of reasonable calculus. > Index Scan using t11_pkey on t11 (cost=0.29..4.31 rows=1 width=9) Index scan runs through several disk (but usually on cache) blocks during descending down to the leaf node in the index tree and does comparisons for certain amount of index entries(tuples) in each index node with regard to btree. The figure made from the expected number of the comparisons multiplied by cpu_operator_cost. Each access methods (index types) has their own function to do that. =# select amname, amcostestimate from pg_am where amname = 'btree'; amname | amcostestimate --------+---------------- btree | btcostestimate The function 'btcostestimate' in selfuncs.c calculates it for btree index. You can see the details there if you wish. regards, -- Kyotaro Horiguchi NTT Open Source Software Center -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs