Re: Add pgstathashindex() to get hash index table statistics. - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Add pgstathashindex() to get hash index table statistics.
Date
Msg-id CAA4eK1LW_JhZg4J7e365koLtnvxo4KOBaGnP5nG7-A8ONQj_Ow@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Add pgstathashindex() to get hash index table statistics.  (Ashutosh Sharma <ashu.coek88@gmail.com>)
List pgsql-hackers
On Thu, Mar 23, 2017 at 11:24 PM, Ashutosh Sharma <ashu.coek88@gmail.com> wrote:
> Hi,
>
> On Tue, Feb 7, 2017 at 9:23 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>> On Mon, Feb 6, 2017 at 10:40 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
>>>> Maybe we should call them "unused pages".
>>>
>>> +1.  If we consider some more names for that column then probably one
>>> alternative could be "empty pages".
>>
>> Yeah, but I think "unused" might be better.  Because a page could be
>> in use (as an overflow page or primary bucket page) and still be
>> empty.
>>
>
> Based on the earlier discussions, I have prepared a patch that would
> allow pgstathashindex() to show the number of unused pages in hash
> index. Please find the attached patch for the same. Thanks.
>
 else if (opaque->hasho_flag & LH_BITMAP_PAGE) stats.bitmap_pages++;
+ else if (PageIsEmpty(page))
+ stats.unused_pages++;

I think having this check after PageIsNew() makes more sense then
having at the place where you currently have, other than that
code-wise your patch looks okay, although I haven't tested it.

I think this should also be tracked under PostgreSQL 10 open items,
but as this is not directly a bug, so not sure, what do others think?

-- 
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: Declarative partitioning optimization for large amountof partitions
Next
From: Amit Kapila
Date:
Subject: Re: comments in hash_alloc_buckets