Hello
Our postgreSQL database is suffering from too many IDLE connections and I'm
wondering if this has to do with isolation level which we usually set to
AUTOCOMMIT.
When I use the default connection settings then checked-in connections do
not appear as IDLE in postgres:
engine = create_engine("postgresql://*@localhost:5432/postgres")
conn1 = engine.connect()
conn2 = engine.connect()
conn2.close()
print(conn1.execute("select state from pg_stat_activity where
usename='souma'").fetchall())
print(engine.pool.status())
*[('active',)]*
*Pool size: 5 Connections in pool: 1 Current Overflow: -3 Current Checked
out connections: 1*
However if I set the Isolation level to AUTOCOMMIT then the checked-in
connection appears as IDLE in postgres:
engine = create_engine("postgresql://*@localhost:5432/postgres")
conn1 = engine.connect()
conn2 = engine.connect()
conn2.close()
print(conn1.execute("select state from pg_stat_activity where
usename='souma'").fetchall())
print(engine.pool.status())
*[('active','idle')]*
*Pool size: 5 Connections in pool: 1 Current Overflow: -3 Current Checked
out connections: 1*
I was wondering if:
1. There was a reason for this difference in behaviour? Should a
checked-in connection show up as 'IDLE'?
2. It is recommended to disable the pool when using autocommit?
Thanks !
Soumaya
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/1f6b6767-4d38-4de9-903f-28e49e92a8b8n%40googlegroups.com.