public inbox for [email protected]
help / color / mirror / Atom feedFrom: hubert depesz lubaczewski <[email protected]>
To: Shaozhong SHI <[email protected]>
Cc: pgsql-sql <[email protected]>
Subject: Re: How to do things like \timing on in a do loop?
Date: Sun, 16 Oct 2022 11:21:35 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+i5JwbMGFD_Yu93oHgqvq3zmftRp4OsLjkyRUKob4oQDkDe_w@mail.gmail.com>
References: <CA+i5JwbMGFD_Yu93oHgqvq3zmftRp4OsLjkyRUKob4oQDkDe_w@mail.gmail.com>
On Sat, Oct 15, 2022 at 08:32:59PM +0100, Shaozhong SHI wrote:
> DO
> $do$
> declare
>
> j int=1;
>
> BEGIN
>
> for j in 1..100 loop
>
> \timing on
>
> select * from a_table;
>
> end loop;
>
> end
> $$;
>
>
> It appears that \timing on is not allowed in a do statement.
>
> Any alternative to do that in a do statement?
Perhaps explain what you want to do, because from this snippet it is
(for me) definitely not clear.
You're mixing postgresql code (do blocks) and psql commands (\timing).
you're trying to get timing off select, but you're not telling the code
what to do with results of the select.
So, what is the end goal in here? And how will you run it? Via psql?
Some other db access?
depesz
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: How to do things like \timing on in a do loop?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox