joe_g Posted yesterday at 10:31 AM Share Posted yesterday at 10:31 AM Hey experts, I had this cool idea I would love to implement, but so far I didn't manage to do it with good enough performance. I've got some date fields on a page, and I'd like to have years indicate on the pagination pages, like so: What I tried is to read all the results, read all the years for each results, then slice them up in pages. This is way to slow, obviously. Only thing i could think of is to make a nightly batch job that calculates the pagination, but it starts to get a bit messy and could easily be out of sync. This is no life-and-death situation, it's just something I would like to do. If you have any ideas how to solve this I'm curious to hear it. 1 Link to comment Share on other sites More sharing options...
da² Posted yesterday at 02:07 PM Share Posted yesterday at 02:07 PM (edited) Hi, First thing I see is you are trying to display too much pagination. Ten elements is usually enough, with 3 dots in the middle: 1 2 3 4 ... 9992 9993 9994 9995. But then there's no really interest in displaying years. ^^ I bet the problem is only a design question: what kind of data do you want to display to the user? Is is truly ergonomic to display an infinite line of links? Wouldn't it be better to display only years at first, then when user clicks a year, display the pagination? Maybe think about it and you'll find a solution better for user and the developer. 🙂 3 hours ago, joe_g said: What I tried is to read all the results, read all the years for each results, then slice them up in pages. This is way to slow, obviously. Anyway, the solution will be a good designed MySQL query, but never to load "all" data. Edited yesterday at 02:08 PM by da² Link to comment Share on other sites More sharing options...
joe_g Posted yesterday at 07:32 PM Author Share Posted yesterday at 07:32 PM Yes, it's a sidescroll so you can easily swipe right as if the pages form a timeline. Since a page corresponds to the amount of stuff you already see on the current page you get a kind of intuitive feel for how much a year contains. A sort of physical representation of everything that has happened. Although it could become years instead of pages for past years, but it gets a bit tricky with a 2 level pagination perhaps. I imagine you click 2022, see pages and you would need to go back to 2024. Now, since you brought this up. The whole thing could potentially be only months and years instead of pages - but that is equally hard to calculate. Not all months have events and should be represented. Yes it would need to be custom sql, i suppose Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now