From: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: pg_stat_statements: more test coverage |
Date: | 2023-12-27 08:08:37 |
Message-ID: | CAOBaU_YvCnJ0aEcSE-KTRp8YZjyf5OS_=L1RHkjo6RbF4JhqZQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Tue, Dec 26, 2023 at 10:03 PM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> On 24.12.23 03:03, Michael Paquier wrote:
> > - Use a DO block of a PL function, say with something like that to
> > ensure an amount of N queries? Say with something like that after
> > tweaking pg_stat_statements.track:
> > CREATE OR REPLACE FUNCTION create_tables(num_tables int)
> > RETURNS VOID AS
> > $func$
> > BEGIN
> > FOR i IN 1..num_tables LOOP
> > EXECUTE format('
> > CREATE TABLE IF NOT EXISTS %I (id int)', 't_' || i);
> > END LOOP;
> > END
> > $func$ LANGUAGE plpgsql;
>
> I tried it like this first, but this doesn't register as separately
> executed commands for pg_stat_statements.
I was a bit surprised by that so I checked locally. It does work as
expected provided that you set pg_stat_statements.track to all:
=# select create_tables(5);
=# select queryid, query from pg_stat_statements where query like 'CREATE%';
queryid | query
----------------------+-----------------------------------------
-4985234599080337259 | CREATE TABLE IF NOT EXISTS t_5 (id int)
-790506371630237058 | CREATE TABLE IF NOT EXISTS t_2 (id int)
-1104545884488896333 | CREATE TABLE IF NOT EXISTS t_3 (id int)
-2961032912789520428 | CREATE TABLE IF NOT EXISTS t_4 (id int)
7273321309563119428 | CREATE TABLE IF NOT EXISTS t_1 (id int)
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Guo | 2023-12-27 09:30:01 | Revise the Asserts added to bimapset manipulation functions |
Previous Message | Nisha Moond | 2023-12-27 07:35:23 | Re: Intermittent failure with t/003_logical_slots.pl test on windows |