> 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
0001-Add-pgstathashindex-to-pgstattuple-extension-v5.patch
Description: invalid/octet-stream
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers