[sqlalchemy] Seek for help - Python process stuck at _exec_once_mutex during first_connect in sqlalchemy/event/attr.py

2023-01-27 Thread Ping Zhang
Hi all, Our production system is experiencing a very strange behavior. At peak load, we see some of our python processes were stuck due to: * in* *with self._exec_once_mutex in sqlalchemy/event/attr.py*, (here is the full stack trace

Re: [sqlalchemy] Queries Across 13 Models - How to improve efficiency?

2023-01-27 Thread Simon King
It looks like all your models share the same "id" value - is that right? If so, you ought to be able to load all of them in a single query, something like this (untested): def getmodels(dbsession, id): models = [M1, M2, M3] conditions = [(M.id == id) for M in models] instances =