"select * from pg_stat_activity" for listing the existing connections, there are 100+ open connections with the state "idle in transaction" with the below query
Query :
SELECT c.oid, a.attnum, a.attname, c.relname, n.nspname,
a.attnotnull OR (t.typtype = 'd' AND t.typnotnull),
a.attidentity != '' OR pg_catalog.pg_get_expr(d.adbin, d.adrelid) LIKE '%nextval(%'
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON (c.relnamespace = n.oid)
JOIN pg_catalog.pg_attribute a ON (c.oid = a.attrelid)
JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid)
LEFT JOIN pg_catalog.pg_attrdef d ON (d.adrelid = a.attrelid AND d.adnum = a.attnum)
JOIN (SELECT 21826 AS oid , 9 AS attnum UNION ALL SELECT 21826, 3) vals ON (c.oid = vals.oid AND a.attnum = vals.attnum)
Google says, its the query for getting the metadata and its generated by framework. I have checked my code base and there is no place where I called this query. I wonder, why these connections are still in *"idle in transaction" state and is still open; which causing the busy connection.