Re: [PATCH v4] pg_stat_statements: Add last_execution_start column

Zsolt Parragi <zsolt.parragi@percona.com>

From: Zsolt Parragi <zsolt.parragi@percona.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2026-06-04T20:54:58Z
Lists: pgsql-hackers
Hello!

The write happens inside the spinlock and shared pgss->lock:

+		/* Record the start time of this execution */
+		entry->last_execution_start = exec_start;
+
 		SpinLockRelease(&entry->mutex);

And then at the read, we see:

 		/*
-		 * The spinlock is not required when reading these two as they are
+		 * The spinlock is not required when reading these three as they are
 		 * always updated when holding pgss->lock exclusively.
 		 */
 		stats_since = entry->stats_since;
 		minmax_stats_since = entry->minmax_stats_since;
+		last_execution_start = entry->last_execution_start;

But that comment doesn't seem true, it is updated with a shared lock,
not exclusive. Shouldn't it be read together with the counters above
this?



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pg_stat_statements: Set PlannedStmt to NULL after nested utility execution