Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core
Commits: f55ccf25 by Abhilash Raj at 2021-04-17T18:17:08-07:00 Improve the performance of paginated queries at /users. This allows slicing the user collection based on the pagination parameters directly in the database layers which avoids having to load all the user rows from database when not needed. This should greatly speed up the API endpoint for users with a large number of registered users. - - - - - b2c30ac2 by Abhilash Raj at 2021-04-18T05:18:16+00:00 Merge branch 'user-query' into 'master' Improve the performance of paginated queries at /users. Closes #876 See merge request mailman/mailman!834 - - - - - 3 changed files: - src/mailman/docs/NEWS.rst - src/mailman/model/usermanager.py - src/mailman/rest/users.py Changes: ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -34,6 +34,8 @@ Bugs * The ``FileNotFound`` exception thrown in CacheManager on attempt to delete an entry for a missing file is now caught. (Closes #867) * Pending probe bounce tokens now have a lifetime of 10 days. (Closes #869) +* Improve the performance of ``/users`` API when paginating by doing the + pagination in database layer. (Closes #876) Command line ------------ ===================================== src/mailman/model/usermanager.py ===================================== @@ -26,6 +26,7 @@ from mailman.model.digests import OneLastDigest from mailman.model.member import Member from mailman.model.preferences import Preferences from mailman.model.user import User +from mailman.utilities.queries import QuerySequence from public import public from sqlalchemy import or_ from zope.interface import implementer @@ -100,7 +101,7 @@ class UserManager: @dbconnection def users(self, store): """See `IUserManager`.""" - yield from store.query(User).order_by(User.id).all() + return QuerySequence(store.query(User).order_by(User.id)) @dbconnection def create_address(self, store, email, display_name=None): ===================================== src/mailman/rest/users.py ===================================== @@ -144,7 +144,7 @@ class _UserBase(CollectionMixin): def _get_collection(self, request): """See `CollectionMixin`.""" - return list(getUtility(IUserManager).users) + return getUtility(IUserManager).users @public View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/9acbf19732df511a571a17a39328e05235859c50...b2c30ac2e9ed39274a7c9603d96ce28c50bab868 -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/9acbf19732df511a571a17a39328e05235859c50...b2c30ac2e9ed39274a7c9603d96ce28c50bab868 You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list -- mailman-checkins@python.org To unsubscribe send an email to mailman-checkins-le...@python.org https://mail.python.org/mailman3/lists/mailman-checkins.python.org/ Member address: arch...@jab.org