Re: Stats collector's idx_blks_hit value is highly misleading in practice

From: Sergey Dudoladov <sergey(dot)dudoladov(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
Subject: Re: Stats collector's idx_blks_hit value is highly misleading in practice
Date: 2022-06-29 20:42:44
Message-ID: CAA8Fd-rOJCR5-c8HqH758dcfDwXPiAUKSJa-N-Bujes9Hz5zuQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I would like to get some feedback on that task.

> pg_statio_*_tables.idx_blks_hit are highly misleading in practice
> because they fail to take account of the difference between internal
> pages and leaf pages in B-Tree indexes.

I see it is still the case, so the issue is relevant, isn't it ?

> The main challenge would be
> passing information about what page we're dealing with (internal/leaf)
> to the place actually calling pgstat_count_buffer_(read|hit). That
> happens in ReadBufferExtended, which just has no idea what page it's
> dealing with. Not sure how to do that cleanly ...

I do not immediately see the way to pass the information in a
completely clean manner.

Either
(1) ReadBufferExtended needs to know the type of an index page (leaf/internal)
or
(2) caller of ReadBufferExtended that can check the page type needs to learn
if there was a hit and call pgstat_count_buffer_(read|hit) accordingly.

In either case necessary code changes seem quite invasive to me.
I have attached a code snippet to illustrate the second idea.

Regards,
Sergey

Attachment Content-Type Size
poc_statistics_collector_index_leaf_pages.patch text/x-patch 3.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2022-06-29 20:42:53 Re: Can we do something to help stop users mistakenly using force_parallel_mode?
Previous Message Daniel Gustafsson 2022-06-29 19:50:45 Re: TAP output format in pg_regress