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().execution_options(isolation_level="AUTOCOMMIT")
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 sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/ac8f3db5-acc3-48b9-9b3a-2aeda8dd35c9n%40googlegroups.com.

Reply via email to