News for hackers. Stuff that matters.
Re:Pagination 101 by chrismorgan on Tuesday February 02, 2016 @12:08AM (#11017715)
One related idea (to do with pagination itself, not just the pagination controls) I’ve had that I’ve never seen actually implemented:

Where showing n elements per page, if the last page would have no more than ε elements in it, merge it with the previous page.

e.g. n = 10, ε = 2, so a data set of 21 elements might go over two pages of 10 and 11 elements rather than three of 10, 10 and 1.

Sure, SQL LIMIT queries and all that, but it’d tend to be nicer for the user.

Re:Pagination 101 by ZeroGravitas on Tuesday February 02, 2016 @05:34AM (#11018647)
If I was paging through 10 items at a time, and noticed that there were 10 pages, I'd assume there was only 91-100 items and if I knew there was actual 103 I'd be more likely to think the site was broken than to look at the bottom of the last page of results for them.
Re:Pagination 101 by stevelosh on Tuesday February 02, 2016 @06:28AM (#11018827)
Django's built-in pagination supports this: https://docs.djangoproject.com/en/1.9/topics/pagination/#opt...
Re:Pagination 101 by chrismorgan on Tuesday February 02, 2016 @05:17PM (#11023125)
Although I work in Django routinely I haven’t had to touch pagination stuff for ages and wasn’t aware it had orphan control. I’m delighted!
Re:Pagination 101 by coolsunglasses on Tuesday February 02, 2016 @03:48AM (#11018313)
>Sure, SQL LIMIT queries and all that, but it’d tend to be nicer for the user.

You'd need to keep a count to do that and a lot of tables you'd bother to paginate, a COUNT() is way too expensive.

Okay so lets say you keep a cache of the COUNT().

What if you're off? Now you have confusing, irregular behavior that throws the user off.

Is this something you've tried in an actual application before?

Re:Pagination 101 by anon4 on Tuesday February 02, 2016 @04:18AM (#11018413)
So SELECT yada yada LIMIT n + epsilon + 1, and if you get that many elements out, display n, otherwise, display all of them.
Re:Pagination 101 by Pharaoh2 on Tuesday February 02, 2016 @03:56AM (#11018341)
Count on an indexed column is a pretty fast operation and it's always correct.
Re:Pagination 101 by calpaterson on Tuesday February 02, 2016 @07:48AM (#11019098)
count(*) is a linear time operation (roughly to the size of the table) on postgres. It does an index-only scan but with a sufficiently large table/index it's still a problem. It's to do with postgres MVCC implementation. I don't know if other SQL databases have this problem. MySQL doesn't seem to.
Re:Pagination 101 by anarazel on Tuesday February 02, 2016 @09:19AM (#11019516)
It's a problem in mysql too, unless you use an engine like myisam, which isn't realistic in most scenarios due to durability and concurrency concerns.