The pagination module should have some limit, or a warning should be given in the documentation
|Reported by:||Mike Lissner||Owned by:||Daniel Jilg|
|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:7 Changed 8 months ago by
|Owner:||changed from nobody to Daniel Jilg|
|Status:||new → assigned|