postgresql has more DB connection in staging servers than production server We have postgresql 9.5 where we use it for an application confluence.
in staging and in production both max connection is same.
But we see staging uses more connection than production e.g staging has 170 connection to DB and production has 105.where as staging is very rarely used.
and among 170 connection 169 is idle.

can any body explain this behavior where highly used Db has less used connection and rarely used application has more used connection.
This is a little hard to guess at because it might be something unique to your staging setup, but here are some things to investigate:


Do you have either multiple staging environments that share the same database?
Do your developers attach to the staging database at all in the course of their work? Every open client is going to use database connections.


Many clients will identify themselves, and you query for current clients with this SQL taken from this posting:


SELECT * 
FROM pg_stat_activity
WHERE datname = 'mydatabasename'


If you compare the results you might find the culprit.