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 1pVCxa-0005mc-6n for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Feb 2023 14:52:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pVCxX-0003gf-V8 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Feb 2023 14:52:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pVCxX-0003gW-Lq for pgsql-hackers@lists.postgresql.org; Thu, 23 Feb 2023 14:52:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pVCxV-0002LT-9n for pgsql-hackers@lists.postgresql.org; Thu, 23 Feb 2023 14:52:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 31NEqFkO414446; Thu, 23 Feb 2023 09:52:15 -0500 From: Tom Lane To: Heikki Linnakangas cc: Peter Eisentraut , Nikolay Samokhvalov , Kirk Wolak , PostgreSQL Hackers , Pavel Stehule , amborodin86@gmail.com, Laurenz Albe Subject: Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has) In-reply-to: References: <157609.1677088525@sss.pgh.pa.us> <2f1c8cb9-6f4d-2a03-d069-c4f9c2b574ab@enterprisedb.com> Comments: In-reply-to Heikki Linnakangas message dated "Thu, 23 Feb 2023 14:09:19 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <414444.1677163935.1@sss.pgh.pa.us> Date: Thu, 23 Feb 2023 09:52:15 -0500 Message-ID: <414445.1677163935@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Heikki Linnakangas writes: > On 23/02/2023 13:20, Peter Eisentraut wrote: >> If you don't have \timing turned on before the query starts, psql won't >> record what the time was before the query, so you can't compute the run >> time afterwards. This kind of feature would only work if you always >> take the start time, even if \timing is turned off. > Correct. That seems acceptable though? gettimeofday() can be slow on > some platforms, but I doubt it's *that* slow, that we couldn't call it > two times per query. Yeah, you'd need to capture both the start and stop times even if \timing isn't on, in case you get asked later. But the backend is going to call gettimeofday at least once per query, likely more depending on what features you use. And there are inherently multiple kernel calls involved in sending a query and receiving a response. I tend to agree with Heikki that this overhead would be unnoticeable. (Of course, some investigation proving that wouldn't be unwarranted.) regards, tom lane