Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion homeassistant/components/recorder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,18 @@ def _commit_event_session(self):
if dbstate in self.event_session:
self.event_session.expunge(dbstate)
self._pending_expunge = []
self._pending_state_attributes = {}
self.event_session.commit()

# We just committed the state attributes to the database
# and we now know the attributes_ids. We can save
# a many selects for matching attributes by loading them
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can save many selects

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it in my typing cleanup branch. I pulled out just the __init__.py file into a smaller PR: #68551

# into the LRU cache now.
for state_attr in self._pending_state_attributes.values():
self._state_attributes_ids[
state_attr.shared_attrs
] = state_attr.attributes_id
self._pending_state_attributes = {}

# Expire is an expensive operation (frequently more expensive
# than the flush and commit itself) so we only
# do it after EXPIRE_AFTER_COMMITS commits
Expand Down