Обсуждение: execution time and running time difference

Поиск
Список
Период
Сортировка

execution time and running time difference

От
jian xu
Дата:

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

 

Re: execution time and running time difference

От
Jeff Janes
Дата:
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