cost_index()

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: cost_index()
Date: 2014-10-27 14:54:22
Message-ID: 544E5C9E.6010806@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

Some fragment of code (src/backend/optimizer/path/costsize.c, lineno ~400):
/*
* Normal case: apply the Mackert and Lohman formula, and then
* interpolate between that and the correlation-derived result.
*/
pages_fetched = index_pages_fetched(tuples_fetched,
baserel->pages,
(double) index->pages,
root);
if (indexonly)
pages_fetched = ceil(pages_fetched * (1.0 - baserel->allvisfrac));

As I understand the code, index_pages_fetched() returns summary of page's read
for index and heap together. But on next line this recalculates with "all
visible fraction" of heap. After recent vacuum it could be 1.0 and then
pages_fetches will be zero. It seems to me obviously wrong, because it's for
index only scan it could be true only for heap, not for index pages.

Am I wrong or miss something?

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-10-27 15:00:44 Re: cost_index()
Previous Message Stephen Frost 2014-10-27 14:48:19 Re: Review of GetUserId() Usage