patternsqlMajor
What does IDLE state denotes in a row of pg_stat_activity?
Viewed 0 times
denoteswhatpg_stat_activitystatedoesrowidle
Problem
Can someone resolve my below doubts about
pg_stat_activity in terms of postgres 9.5?- Can some let me know what does the
stateIDLEdenotes in the row ofpg_stat_activity? Is it like it checks all the open connections to postgres and if the connection is not executing any query thenIDLEdenotes the last query executed by the connection?
- In the output of
select * from pg_stat_activityI am seeing rows withstateIDLEand thequery_start_datemore than 2 days old? What does this signify ? Should I be worried about this?
- Can someone let me know how pg_stat_activity is populated? If I am executing a query like
Select * from pg_stat_activitydoes it produce the details from some snapshot maintained by postgres or it checks the current connections open in postgres to provide the details?
Solution
This has been answered in postgres mailing list
Each row in pg_stat_activity represents an established connection to
the server from a client. "idle" means the client is not currently
executing a query nor in a transaction.
If query_start_date is 2 days old, that just means the last query to
be executed on that connection was two days ago.
Not really a reason for worry, unless you have so many connections
open that it's consuming more RAM than you can afford. It's generally
desirable for a connection pool to have a few idle connections so
queries don't suffer the latency of establishing a new connection.
Each row in pg_stat_activity represents an established connection to
the server from a client. "idle" means the client is not currently
executing a query nor in a transaction.
If query_start_date is 2 days old, that just means the last query to
be executed on that connection was two days ago.
Not really a reason for worry, unless you have so many connections
open that it's consuming more RAM than you can afford. It's generally
desirable for a connection pool to have a few idle connections so
queries don't suffer the latency of establishing a new connection.
Context
StackExchange Database Administrators Q#202006, answer score: 42
Revisions (0)
No revisions yet.