Re: pg_stat_statements: Avoid holding excessive lock
wenhui qiu <qiuwenhuifx@gmail.com>
From: wenhui qiu <qiuwenhuifx@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Karina Litskevich <litskevichkarina@gmail.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-11-08T09:49:45Z
Lists: pgsql-hackers
Hi Karina Liskevich > + /* > + * There is no need to hold entry->mutex when reading stats_since and > + * minmax_stats_since for (unlike counters) they are always written > + * while holding pgss->lock exclusively. We are holding pgss->lock > + * shared so there should be no race here. > + */ > stats_since = entry->stats_since; > minmax_stats_since = entry->minmax_stats_since; > - SpinLockRelease(&entry->mutex); >> The comment could be simpler, say a "The spinlock is not required when >> reading these two as they are always updated when holding pgss->lock >> exclusively.". Or something like that. Agree , It reduces the lock time , The new comment are short and concise, It sounds good . Michael Paquier <michael@paquier.xyz> 于2024年11月8日周五 14:08写道: > On Thu, Nov 07, 2024 at 04:08:30PM +0300, Karina Litskevich wrote: > > Thank you for your feedback and the shorter wording of the comment. > > I used it in the new version of the patch. > > After a second look, sounds good to me. Let's wait a bit and see of > others have comments or thoughts to share. > -- > Michael >
Commits
-
pg_stat_statements: Avoid some locking during PGSS entry scans
- 5d4298e75f25 18.0 landed