Hi!

I'm trying to get an efficient pagination with MongoDB and Wicket working.
The problem with MongoDB is, that the skip operation can become really
expensive on large datasets (basically every time you really need
pagination). So the best practice for pagination in MongoDB is to make
range queries. So you build your query and limit it to i.e. 50 documents,
if you need the next 50 you make the same query, but specify that you are
only interested in objects where the objectId is higher than in the last
item of the last query and so on.
The Wicket IDataProvider unfortunately only gives you the primitive long to
work with, which is insufficient for this case.
Another problem with MongoDB is, that even "count" can become quite
expensive. So I would like to avoid to give the total amount of available
items from the beginning.
Currently I  have a "google like" pagination in mind where the
PagingNavigator only shows 10 or so page links and as the user goes through
the pages it dynamically adds more page links to the end and removes the
first links at the beginning.
But unfortunately I'm kinda stuck. I tried to create some kind of
IRangeDataProvider<I> where I is a datatype for the range based query and
replaces the long for skipping. But now I have to carry this through
everything like DataView, DataBaseView and all the interfaces. Thats not
nice, since it could also be needed to dynamically alter the type of the
"range item" for example if you change the sorting. Apart from that I tink
I ran into many more problems so that I am as far away from a working
protype as I can be.
So I am asking here for help. Probably some of the more experienced Wicket
developers (more experienced than me) already build something like that or
even published a small library project for this use case.

Thanks in advance

Regards,

Till

Reply via email to