Re: execution time and running time difference

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: jian xu <jamesxu(at)outlook(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: execution time and running time difference
Date: 2023-07-28 17:38:57
Message-ID: CAMkU=1yVdVYMnbGH_u24Ux+DaqiSmTAAARnUEomEVY_bvL4vow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Fri, Jul 28, 2023 at 10:58 AM jian xu <jamesxu(at)outlook(dot)com> wrote:

> Hello,
>
> I enabled the \timing in psql, and run a query with explain
> analyze,
>
> In the output, the execution time(from analyze) is 28 seconds, the query
> only returns 14 rows, however the Time(from timing) is more than a minute.
> Could someone help me explain the difference between execution time and
> running time? And how did it happen, any possible cause? Thanks
>
> James
>
>
>

Time needed to acquire a table lock will be included in \timing, but
(generally) not in explain analyze, so that is a very plausible
explanation. If you turned on log_lock_waits, you could look in the log
file to see if there were any long blockings at this time.

Or if you are connecting through pgbouncer with statement or transaction
pooling, maybe it just took a while for a real connection to
become available.

Cheers,

Jeff

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Erik Serrano 2023-07-29 19:40:30 Re: Is a PS - MSSQL Logical Replication Possible??
Previous Message jian xu 2023-07-28 14:58:30 execution time and running time difference