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

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: Kuntal Ghosh <kuntalghosh(dot)2007(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-24 04:39:58
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

> I've looked at the patch. It looks good. However, I was wondering why
> an exclusive lock for extension is necessary for reading the number
> blocks in this case. Please refer to the following code.
> + /* Get the current relation length */
> + LockRelationForExtension(rel, ExclusiveLock);
> + nblocks = RelationGetNumberOfBlocks(rel);
> + UnlockRelationForExtension(rel, ExclusiveLock);
> Apart from this, I've nothing else to add.

Actually in my case I may not need to acquire ExclusiveLock just to
get the number of pages in a relation. Infact I have already opened a
relation using
'AccessShareLock' which should be enough to read a table length.
Thanks for putting this point. I have corrected it in the attached v5
patch. I think
in 'pgstat_index()' currently LockRelationForExtension(rel,
ExclusiveLock); is being used just to read a table length which I feel
is not required. You may raise this point in the community in a
separete mail thread if you agree with it. Also, I guess
LockRelationForExtension() is used when trying to add a new page in an
existing relation so not sure if it would be right to call it from
contrib modules like pgstattuple where we are just trying to read the

With Regards,
Ashutosh Sharma

Attachment Content-Type Size
0001-Add-pgstathashindex-to-pgstattuple-extension-v5.patch invalid/octet-stream 17.6 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-01-24 04:45:38 Re: [PATCH] Rename pg_switch_xlog to pg_switch_wal
Previous Message Craig Ringer 2017-01-24 04:36:35 Re: Faster methods for getting SPI results (460% improvement)