Re: Improve explicit cursor handling in pg_stat_statements
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Sami Imseih <samimseih@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-06-03T08:09:18Z
Lists: pgsql-hackers
On Mon, Jun 02, 2025 at 02:44:36PM -0500, Sami Imseih wrote:
> Since the FETCH case is clear-cut, here is a patch that normalizes variable
> fetch sizes in a FETCH command. At a minimum, we can apply this patch.
> I’ve also added tests in pg_stat_statements utility.sql to demonstrate
> how queryIds
> are grouped for the variants of the FETCH statement.
{
NodeTag type;
FetchDirection direction; /* see above */
- long howMany; /* number of rows, or position argument */
+ /* number of rows, or position argument */
+ long howMany pg_node_attr(query_jumble_ignore);
char *portalname; /* name of portal (cursor) */
bool ismove; /* true if MOVE */
+ ParseLoc location pg_node_attr(query_jumble_location);
} FetchStmt;
In terms of silencing the numbers, that's fine by me. Now one issue
is that this also masks FETCH_ALL which is a specific keyword in the
grammar.
Should we offer something more consistent with DeallocateStmt, where
we have a boolean flag that would be set when ALL is specified,
included in the jumbling? This would mean two separate entries: one
for the constants and one for ALL.
--
Michael
Commits
-
Show sizes of FETCH queries as constants in pg_stat_statements
- bee23ea4ddc4 19 (unreleased) landed