public inbox for [email protected]
help / color / mirror / Atom feedHow to do things like \timing on in a do loop?
3+ messages / 3 participants
[nested] [flat]
* How to do things like \timing on in a do loop?
@ 2022-10-15 19:32 Shaozhong SHI <[email protected]>
2022-10-15 20:04 ` Re: How to do things like \timing on in a do loop? Erik Brandsberg <[email protected]>
2022-10-16 09:21 ` Re: How to do things like \timing on in a do loop? hubert depesz lubaczewski <[email protected]>
0 siblings, 2 replies; 3+ messages in thread
From: Shaozhong SHI @ 2022-10-15 19:32 UTC (permalink / raw)
To: pgsql-sql <[email protected]>
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?
Regards,
David
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to do things like \timing on in a do loop?
2022-10-15 19:32 How to do things like \timing on in a do loop? Shaozhong SHI <[email protected]>
@ 2022-10-15 20:04 ` Erik Brandsberg <[email protected]>
1 sibling, 0 replies; 3+ messages in thread
From: Erik Brandsberg @ 2022-10-15 20:04 UTC (permalink / raw)
To: Shaozhong SHI <[email protected]>; +Cc: pgsql-sql <[email protected]>
You can't, as \timing is not a postgres command. It is a psql command, so
is not interpreted by the server itself.
On Sat, Oct 15, 2022, 3:33 PM Shaozhong SHI <[email protected]> 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?
>
> Regards,
>
> David
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to do things like \timing on in a do loop?
2022-10-15 19:32 How to do things like \timing on in a do loop? Shaozhong SHI <[email protected]>
@ 2022-10-16 09:21 ` hubert depesz lubaczewski <[email protected]>
1 sibling, 0 replies; 3+ messages in thread
From: hubert depesz lubaczewski @ 2022-10-16 09:21 UTC (permalink / raw)
To: Shaozhong SHI <[email protected]>; +Cc: pgsql-sql <[email protected]>
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-10-16 09:21 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-15 19:32 How to do things like \timing on in a do loop? Shaozhong SHI <[email protected]>
2022-10-15 20:04 ` Erik Brandsberg <[email protected]>
2022-10-16 09:21 ` hubert depesz lubaczewski <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox