In Postgres 14 in pg_stat_statements, why is there a huge time difference between max_exec_time and mean_exec_time?
Could you please help?

In Postgres 14 in pg_stat_statements, why is there a huge time difference between max_exec_time and mean_exec_time?
Could you please help?

Copyright © 2021 Jogjafile Inc.
That means that the execution time varies considerably. To see if that is just a single outlier or a regular occurrence, see if
stddev_exec_timeis high or not.It can mean several things:
Perhaps execution sometimes took long because the statement was stuck behind a lock. If that is a rare occurrence, it may me the odd
ALTER TABLEstatement.Perhaps the execution time varies depending on a query parameter. It may be fast for rare values and slow for frequent ones. Test with different parameters!
Perhaps execution time varies depending on how much of the data happens to be cached in RAM. Look at a high "buffers" footprint in the
EXPLAIN (ANALYZE, BUFFERS)output.