Commit 8413ae86 authored by Aurélien Bompard's avatar Aurélien Bompard Committed by Barry Warsaw

Optimize the roster SQL query

Measured improvement: about 100x faster. (!)

Reformatting.
parent 8040aeab
Pipeline #278514 passed with stage
......@@ -286,9 +286,11 @@ class Memberships:
@dbconnection
def _query(self, store):
results = store.query(Member).filter(
or_(Member.user_id == self._user.id,
and_(Address.user_id == self._user.id,
Member.address_id == Address.id)))
Member.user_id == self._user.id
).union(
store.query(Member).join(Address).filter(
Address.user_id == self._user.id)
)
return results.distinct()
@property
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment