From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: stored procedures vs pg_stat_statements |
Date: | 2024-12-24 23:38:32 |
Message-ID: | Z2tF-K3olYsbK5g5@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Dec 24, 2024 at 08:23:57AM -0600, Merlin Moncure wrote:
> Actually, I hadn't gotten that far yet; I was just noticing that:
> CALL foo(1,2,3);
> CALL foo(2,3,4);
> ...resolved to different queryids and if that was expected, and if not, if
> some logic tune-ups in the extension improve behavior without deeper
> changes.
Oh, yeah, definitely. This has been a severe issue for some customers
I'm dealing with that have a heavy workload based on CALL who also
wish to track utilities on top of non-utility queries. This level of
normalization is supported since 17~ and commit 11c34b342bd7, so you
would need to upgrade if you want that support natively as this
requires in-core backend adjustments:
CREATE OR REPLACE PROCEDURE sum_two(i int, j int) AS $$
DECLARE
r int;
BEGIN
SELECT (i+j)::int INTO r;
END; $$ LANGUAGE plpgsql;
CALL sum_two(1,1);
CALL sum_two(2,1000);
CALL sum_two(3,3);
SELECT calls, query FROM pg_stat_statements WHERE query ~ 'CALL';
calls | query
-------+---------------------
3 | CALL sum_two($1,$2)
(1 row)
One piece of facility that was lacking is support for query jumbling
with the parsing nodes of utilities, which was larger than this
specific commit, still it allowed the change. If you see other areas
that could make pgss more useful with more utility normalization, feel
free to point them out. The point would be then to figure out which
portions of the parsing nodes need to be ignored in the query
jumbling and the constant locations.
contrib/pg_stat_statements/sql/utility.sql has a test section
dedicated to CALL, FWIW.
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2024-12-25 01:10:44 | Autovacuum giving up on tables after crash because of lack of stats |
Previous Message | Rahila Syed | 2024-12-24 20:37:46 | Re: Enhancing Memory Context Statistics Reporting |