3

I'm new to postgres , I've aws rds instance running postgresql with engine version 11.5.

All my queries are clientRead has the wait_event. Why do I have all my queries in idle status.Does this mean they are idle in transaction?

What are the steps should I take to fix this?

If I change to idle_in_transaction_session_timeout to 10 mins for example will it fix this?

select count(*),state FROM pg_stat_activity group by 2;
 count | state
-------+--------
     5 |
     1 | active
   451 | idle


Select pid, datname, usename, wait_event_type, wait_event, backend_type FROM pg_stat_activity where state='idle';
  pid  | datname  |         usename          | wait_event_type | wait_event |  backend_type
-------+----------+--------------------------+-----------------+------------+----------------
 14797 | xxxxx    | user                     | Client          | ClientRead | client backend


SELECT current_setting('idle_in_transaction_session_timeout');
 current_setting
-----------------
 1d
(1 row)
0

1 Answer 1

7

Your session is in idle state, not the query.

Sessions that are idle are not a problem. It simply means the backend is waiting for the client to send a SQL query.

The number of sessions is a little bit on the high side though. You will need to have a really powerful server to cope with that, once all of them start doing something.

Sessions that are idle in transaction would be a problem if they stayed in that state for too long. That's what the idle_in_transaction_session_timeout handles, not "idle" sessions.

1
  • so, if someone said an application was crashing because of 'idle' postgres connections, it is save to advise to search for a solution outside of postgres, correct?
    – vrms
    Apr 13 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.