mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Prevent sqlalchemy from refetching the old_state_id as it will never change (#40982)
Disable expire_on_commit for the event writer. Since we never expect the old_state_id to change in the database, it was never worth the expense of refetching the id after the commit.
This commit is contained in:
parent
fd91d21b28
commit
953a1ddc8c
@ -573,7 +573,9 @@ class Recorder(threading.Thread):
|
||||
sqlalchemy_event.listen(self.engine, "connect", setup_recorder_connection)
|
||||
|
||||
Base.metadata.create_all(self.engine)
|
||||
self.get_session = scoped_session(sessionmaker(bind=self.engine))
|
||||
self.get_session = scoped_session(
|
||||
sessionmaker(bind=self.engine, expire_on_commit=False)
|
||||
)
|
||||
|
||||
def _close_connection(self):
|
||||
"""Close the connection."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user