Thread: Re: pg_stat_statements: Avoid holding excessive lock

Re: pg_stat_statements: Avoid holding excessive lock

From
wenhui qiu
Date:
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