Re: [PATCH v5] pg_stat_statements: Add last_execution_start column

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Pavlo Golub <pavlo.golub@cybertec.at>
Cc: Sami Imseih <samimseih@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-06-10T18:03:37Z
Lists: pgsql-hackers
Hi,

On 2026-06-10 17:36:24 +0000, Pavlo Golub wrote:
> @@ -1490,6 +1509,10 @@ pgss_store(const char *query, int64 queryId,
>  		else if (planOrigin == PLAN_STMT_CACHE_CUSTOM)
>  			entry->counters.custom_plan_calls++;
>  
> +		/* Record the start time of this execution, if provided */
> +		if (exec_start != 0)
> +			entry->last_execution_start = exec_start;
> +
>  		SpinLockRelease(&entry->mutex);
>  	}

FWIW, I remain opposed to adding *any* additional thing under the spinlock. We
first need to fix the design of pgss, then we can start discussing expanding
it even further.

I've seen way too many instances being brought to their knee because of pgss
contention.  We shouldn't make it even worse.

Greetings,

Andres Freund



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