Merge lp:~flo-fuchs/mailman/db_collection_limit_prototype into lp:mailman
Status: | Work in progress |
---|---|
Proposed branch: | lp:~flo-fuchs/mailman/db_collection_limit_prototype |
Merge into: | lp:mailman |
Diff against target: |
250 lines (+180/-4) 5 files modified
src/mailman/database/base.py (+29/-0) src/mailman/database/tests/test_db_result_list.py (+125/-0) src/mailman/model/listmanager.py (+2/-3) src/mailman/model/tests/test_listmanager.py (+22/-0) src/mailman/rest/lists.py (+2/-1) |
To merge this branch: | bzr merge lp:~flo-fuchs/mailman/db_collection_limit_prototype |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Barry Warsaw | Pending | ||
Review via email:
|
Description of the change
Hi Barry,
like discussed on IRC here's a prototype branch to add limit and offset to db results (for pagination etc.).
Initial problem: Currently, if a collection is accessed trough a manager (ListMananager, ...) the manager will turn the storm ResultSet into a list before passing it on. This causes storm to query and return *all* records in the database, even if only a subset is needed.
Solution 1: Instead of turning the ResultSet into a List, the manager could just return the ResultSet itself.
But then the abstraction is lost, the code retrieving the data has to be aware that this is a DB result, use .count instead of len etc.
Solution 2: The ResultSet is turned into a "DBResultList" which is just a list-like proxy around ResultSet. Any code that is using that object can use it like a native list, but access to list items via an index or a start:stop range will cause the SQL query to use a proper limit and offset.
Limitations: At the moment, __setitem__ and __delitem__ are not implemented. The test for the DBResultList is rather isolated and should probably be integrated better with the existing tests. I put the DBResultList class into database/base.py for now.
Cheers
Florian
Unmerged revisions
- 7213. By Florian Fuchs
-
added missing test file...
- 7212. By Florian Fuchs
-
* added DBResultList class to hide db implementation and provide a list-like object
* ListManager uses DBResultList - 7211. By Florian Fuchs
-
db collections