Long lasting 'COMMIT' queries with 'idle' state in pg_stat_activity

后端 未结 1 1366
我寻月下人不归
我寻月下人不归 2021-02-13 02:23

If I query:

select * from pg_stat_activity where application_name ~ \'example-application\';

I get many rows which state is idle a

相关标签:
1条回答
  • 2021-02-13 02:58

    If the session is "idle" the query column shows the last statement that connection has executed. It is not the "current" query, so the connection is not waiting for the commit to finish.

    The query column only shows the current statement if status shows active.

    An "idle" connection is not a problem and essentially the reason why a connection pool is used, so that it can be re-used. However, sessions that stay very long in "idle in transaction" are a problem. But you stated your connections are in "idle" state.

    If your connection pool reaches the limit, this most probably means your application is not returning the connections properly to the pool. It is something you need to fix in your application.

    0 讨论(0)
提交回复
热议问题