Re: execution time and running time difference - Mailing list pgsql-admin

From Jeff Janes
Subject Re: execution time and running time difference
Date
Msg-id CAMkU=1yVdVYMnbGH_u24Ux+DaqiSmTAAARnUEomEVY_bvL4vow@mail.gmail.com
Whole thread Raw
In response to execution time and running time difference  (jian xu <jamesxu@outlook.com>)
List pgsql-admin
On Fri, Jul 28, 2023 at 10:58 AM jian xu <jamesxu@outlook.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

pgsql-admin by date:

Previous
From: jian xu
Date:
Subject: execution time and running time difference
Next
From: Erik Serrano
Date:
Subject: Re: Is a PS - MSSQL Logical Replication Possible??