The pagination module should have some limit, or a warning should be given in the documentation
|Reported by:||mlissner||Owned by:||winsmith|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Perhaps I'm off base on this, but I was just analyzing my slow queries log, and I noticed that the pagination module produces some incredibly slow queries in MySQL when high page numbers are requested. This just took down my server, so I was thinking about possible solutions.
The pagination module is using the OFFSET MySQL clause, which, as I understand it, must iterate over every row up to the OFFSET number in order to work.
The two solutions I thought of for this were:
- Add something to the documentation that indicates how this might produce very slow queries.
- Add code to the pagination module to either:
- Solve the problem with smarter MySQL queries (not sure if/how this is possible, sorry); or
- Allow a max_pages attribute, which throws some kind of error when the max_page number is exceeded. It could even have a sane default, keeping people within normal limits.
Admittedly, 2b is the solution I'm coding up right now, but it would be nice if Django enforced, or at least hinted at, a solution to this problem.
I've also (FWIW) tested pagination on Google, Yahoo, and Bing, and all three limit their results (Bing: page 20, Google: page 100, and Yahoo: page 100).
Change History (15)
comment:1 Changed 6 years ago by PaulM
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:7 Changed 4 months ago by winsmith
- Cc winsmith@… added
- Owner changed from nobody to winsmith
- Status changed from new to assigned
comment:9 Changed 4 months ago by Erik Romijn <eromijn@…>
- Resolution set to fixed
- Status changed from assigned to closed
comment:11 Changed 4 months ago by timgraham
- Has patch unset
- Resolution fixed deleted
- Status changed from closed to new