Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojnP0-0003Bc-SL for pgsql-sql@arkaria.postgresql.org; Sat, 15 Oct 2022 20:04:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ojnOz-00017Q-Ng for pgsql-sql@arkaria.postgresql.org; Sat, 15 Oct 2022 20:04:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojnOz-00016q-Cd for pgsql-sql@lists.postgresql.org; Sat, 15 Oct 2022 20:04:57 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ojnOx-0006NC-0P for pgsql-sql@lists.postgresql.org; Sat, 15 Oct 2022 20:04:56 +0000 Received: by mail-pj1-x1030.google.com with SMTP id a6-20020a17090abe0600b0020d7c0c6650so10935599pjs.0 for ; Sat, 15 Oct 2022 13:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heimdalldata.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KXSXYf7sV0wMeuqa2eckr6+jL8UKomSC9ov73YpAzRE=; b=piHHK3sKNVx43PrlVXL/hRLij7k//FR2hPiXkuKq9vzLN+tA3Vzn4mjxD+5V/TisWL pwU5d/jaJr0OMoq4t7XyEPuqD4hv3WeBKQTuLAToz/FZ/8zobLH5b3oOrZRBzMzeKbru G0xPe949wMSGmkOXT8D6ryHs7WBsRqlnb8AGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KXSXYf7sV0wMeuqa2eckr6+jL8UKomSC9ov73YpAzRE=; b=w81uKWV0TJSA6WARL2j2vtwoKPyFScIegiGNWCL5NXoNMVeAXzTvp7WLZk0gfTu1gB 1KoGnyA1Bl8sJ336+VRRk5GbEGYLy29KCkNWoeujo5/A9SuW+kt8SCBelUN21aQzBoXj BGRbNYbBCb/qfP9uwcDn0AJxxGXXSxQmBwTnKMx9SsGRmzpTkqqow8wMx3ZZB+ffcbyK 9PZ0rxmEYtQAW1Q283QpQUTVtVYYWlGLWGOqtSBQOWNDMGb09JZ1ymJ9fLgmT/tN1Hs2 6fLr2saUhH99SAvkAkm5MPJ4JC2t9rxq6eqtqXuEpP7xmlIxdO4g4mQoQ7KGzNPBWcxq IMVw== X-Gm-Message-State: ACrzQf1PYanfhf9a3MU6pKiZVG3066fXDhAAtCdW9/ntaa+t8pLY9My0 IWRWiyJ9Fbn31RJy0Sw/hcDtL3OA4FMNE5Fw2ldtwA== X-Google-Smtp-Source: AMsMyM6NWXnHBF0O4X2MVXwvtix8Lb1VHzBYYh9PagOr0qRcjgbDZRINI6k/aVu9DO6ZssUqR/s7c8e8+Cdnn7Jmk/E= X-Received: by 2002:a17:902:ff0a:b0:185:293d:dbe3 with SMTP id f10-20020a170902ff0a00b00185293ddbe3mr4133287plj.28.1665864293229; Sat, 15 Oct 2022 13:04:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Erik Brandsberg Date: Sat, 15 Oct 2022 16:04:41 -0400 Message-ID: Subject: Re: How to do things like \timing on in a do loop? To: Shaozhong SHI Cc: pgsql-sql Content-Type: multipart/alternative; boundary="000000000000713e6e05eb184153" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000713e6e05eb184153 Content-Type: text/plain; charset="UTF-8" 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 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 > --000000000000713e6e05eb184153 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You can't, as \timing is not a postgres command.=C2= =A0 It is a psql command, so is not interpreted by the server itself.
=
On Sat= , Oct 15, 2022, 3:33 PM Shaozhong SHI <shishaozhong@gmail.com> wrote:
DO
$do$
declare

j int=3D1;

= BEGIN=C2=A0

for j in 1..100 loop

\timing on

select * from a_table;

end loop;

end
$$;
=


It appears that \timing on is not allowe= d in a do statement.

Any alternative to do that in= a do statement?

Regards,

David
--000000000000713e6e05eb184153--