Re: Add pgstathashindex() to get hash index table statistics.

From: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
To: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add pgstathashindex() to get hash index table statistics.
Date: 2017-01-05 10:24:32
Message-ID: CAGz5QCLKAvPC40FMa3pnG+QojOk9LPaChVki3GiyyTkmQiUm6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 21, 2016 at 7:22 PM, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com> wrote:
> Hi All,
>
> I have introduced a new function 'pgstathashindex()' inside pgstatuple
> extension to view the statistics related to hash index table.
>
I think this feature is going to be helpful. I've some initial review
for the patch.
I've not applied the patch yet.

+ buf = ReadBufferExtended(rel, MAIN_FORKNUM, blkno, RBM_NORMAL, NULL);
Use ReadBuffer() instead.

+ /*
+ * Let us ignore metapage and bitmap page when calculating
+ * free space percentage for tuples in a table.
+ */
+ table_len = (stats.total_pages - 2) * BLCKSZ;
+
+ free_percent = 100.0 * stats.free_space / table_len;
I think the calculation for max available spcae is wrong here. You
should subtract the page header and special area from the total page size.
A check for non-zero denominator should be added while calculating the
percentage.
There can be multiple bitmap pages. Right?

+ values[10] = Float8GetDatum(free_percent);
Some precision should be added.

+ <row>
+ <entry><structfield>ffactor</structfield></entry>
+ <entry><type>integer</type></entry>
+ <entry>Average number of tuples per bucket</entry>
+ </row>
I feel that either the column name should be changed or it should
just output how full the index method is in percentage.

+ </varlistentry>
+
+
+ <varlistentry>
Please remove extra spaces.

And, please add some test cases for regression tests.

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2017-01-05 10:39:54 Re: proposal: session server side variables
Previous Message Stas Kelvich 2017-01-05 10:21:10 Re: logical decoding of two-phase transactions