-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimized pagination? #9
Comments
Before I started this projects, I have done a little research and also found meteor-pages. After tested it and as far as I've understood, the package is great but did not accomplish my project needs since the its scope is much bigger. I think that trying to merge the two packages would be a little messy since both try to solve same user cases but with differents approachs. The main goal of this project is to be a solid tool for Meteor's developers that could be easily integrated with other packages (like iron route) but independent at the same time. If you consider that some particular feature of meteor-pages could be useful to be included in this packages, please let me know or do a pull request and I will look at it enthusiastically. Thanks! |
Hey Julian! Thanks for your kind response. Good to hear you know meteor-pages already. I didn't think merging would be desired, maybe just using it for pagination if the implementation is good, but you're right, I better look into it some more. A glitch I see with the f-c demo is that when the switching pages a longer list flickers up before the next (short) page is shown. And from the f-c readme I couldn't tell which features listed at meteor-pages are coverd, e.g. preloading of next increments, and only adding to the local collection cache (no re-subs mode). Maybe you could add such a list for f-c as well? |
You are right, that is something that I've noticed and I think that this happend because invalidation is performed after the cursor is back to the subscriber so at a first glance, i consider that this could be fixed doing invalidation before subscribing. This will cause a visual document cleanup effect before the new ones are loaded. Let me know your thoughts. Thanks. |
Unfortunately, I know almost nothing about meteor rendering, and user "aldeed" has pointed me to upcoming changes: https://github.com/meteor/meteor/wiki/New-Template-Engine-Preview Let us move our paging related thoughts from "how does it work?" issue here as well. Thoughts for proper differentiation of scoping and pagination on server client: stagesFrom the entire db, the server "scopes" down the data to sync with the client (from throusands of documents to hundreds). usageDesktop client browsers should have absolutely no problem working with hundreds of documents in the (minimongo) cache. Using the cache is fast. Re-subscribing to changed publications (scope changes) should be avoided, because this invalidates and retransmitts all documents. Hopefully, there is a way to broaden a subsribed scope (adding additional documens) without invalidating and re-subscriging. (The meteor-pages description seems to describe that? Start syncing only the first increment, load next in background, keep all previous when switching to next page and loading the next+1 in the backgound.) Clients can subscribe to multiple "scope" publications (differnent filter and sort order), they are then able to switch between sorting and filtering locally, returning up-to date correct results without any re-subs. Maintaining a multi-scope cache will also allow the client to keep working when Depending on the client platform/resources there is a limit to the cache size when performance starts to degrade. Above that limit the client may:
implementationAs multiple scopes get merged into the same synced cache (merge box on server and minimogo on client), correct pagination requires to keep all previous documents in the cache (to be able to select the ones to show). This comes naturally for "infinite scroll", classic pagination will just have to skip the previous entries in the cache. These comments seems to hint to some new build in features though: tmeasday/meteor-paginated-subscription#3 |
A good pattern may be to let the router waitOn the minimum size of the required scope, and preload the minimum sizes of all other basic app scopes in the background after page rendering. |
The distinction, that I think is important, is between scoping (server code) and pagination (client code). Pagination should be done by client code, except when the amount of documents synced according to all subscribed scopes can not be handled efficiently on the client anymore. Usually, one chooses the published scopes so that they don't reveal only a limited set of info from the database and don't overwhelm the client (publish only recent documents, fields relevant to the user, etc.), and pagination can be handled by the client without any re-subs and document re-transmissions (even offline). Nevertheless, if the data that the client is supposed to sort, filter and look at (paginate through) becomes too much to be handled in the client database, the client should be able to request a small separate sync subscription (scope), and store it as a separate client only collection (cache). That separate local collection (with another name than the collection on the server) then really just contains the data that is rendered (optionally plus the previous/next documents of some neigboring increments). Thus the client can reliably use skip and limit locally to paginate through this separately cached and synced server scope (result of server's sort, filter, skip and limit). However, the client now always has to trigger a server query as well, to move the scope. |
Sound interesting. I've read several times all your posts and I think that
How do you imagine a client implementing paging when minimongo does not
I think that here I don't understand what is written. `Nevertheless, if the data that the client is supposed to sort, filter and That separate local collection (with another name than the collection on Well, as far as I know, the package does that. Once you set an FC instance, So to be clear, once the user do something (paging, sorting, filter) the FC Could be very probable that I'm missing some concept to fully understand Thanks a lot! On Tue, Jan 28, 2014 at 9:34 AM, testbird [email protected] wrote:
toOit _Julián Esteban [email protected]* :: +*54 9 11 3468-0401 |
Hi!
Until meteor provides a solution for that (maybe something like dynamically adding ranks and tagging documents with scope skips/offsetts), I think scope publications will just have to sync all documents up to a limit to the client (for every desired sort order without further filtering). Then, I believe, all sort, filter, and pagination results based on minimongo should be ok. This (my) usecase of course requires that one is able to scope down all the data on the server, to a set that consists of all the data the client may require (in the context/template it is currently in), and that the whole set can be handled on the client. (Loading time can still be snappy by waiting only on a small subscription that just syncs what is necessary to render the requested url, and then letting the the full scope subscriptions sync in the background.)
Oh shame on me, that was an ugly typo. Please scratch my "don't" there as well.
Yes, thank you so much again for your explanations, I think now I kind of understand "how filter-collections works". Maybe our conversation can lead to filter-collections supporting both use cases: To easily render and switch the filter, sort, and pagination features on local minimongo datasets, as well as on separately requested server side queries if necessary. Hopefully, my other comments do also make a little more sence to you now? By the way:
I had an idea for another optimization. If, instead of stoping the subscription and creating a new one, you add the new one, and only close the old subscription after the new one is ready, you may avoid retransmitting the documents that are part of both subscriptions. |
To provide an example for the scopes that I believe should work with limited minimongo data subsets. Imagine there are a lot of posts and you publish the 20 most recent, the 20 most popular, and the latest posts from the 20 most active authors. All these end up in (get synced into) the client's minimongo cache. (Skips are not allowed.) Isn't it then so that all filtering and paginating along those sort ranks should also give the correct results on the client (only up to the 20th position of course.)? |
It may be benificial to join/depend on and use the meteor-pages package for its features.
https://github.com/alethes/meteor-pages
The text was updated successfully, but these errors were encountered: