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

From Ashutosh Sharma
Subject Re: [HACKERS] Add pgstathashindex() to get hash index table statistics.
Date
Msg-id CAE9k0PkYu==NvCitEQ0yJbifLq7AydqZ8+RGPFY8mMtrJCq7ag@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Add pgstathashindex() to get hash index table statistics.  (Kuntal Ghosh <kuntalghosh.2007@gmail.com>)
Responses Re: [HACKERS] Add pgstathashindex() to get hash index table statistics.  (Kuntal Ghosh <kuntalghosh.2007@gmail.com>)
List 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
tables.

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: [HACKERS] Faster methods for getting SPI results (460% improvement)
Next
From: Michael Paquier
Date:
Subject: Re: [HACKERS] [PATCH] Rename pg_switch_xlog to pg_switch_wal