ground-db
                                
                                 ground-db copied to clipboard
                                
                                    ground-db copied to clipboard
                            
                            
                            
                        Meteor mobile initial load is very slow when using GroundDB
When this code is included in my Meteor mobile iPad app, the first time the installed app opens it takes several minutes to get beyond initial loading screen. If I comment out this code, the app loads fast.
if(Meteor.isCordova) {
    Ground.Collection(Meteor.users);
    Ground.Collection(Customers);
    Ground.Collection(Projects);
    Ground.Collection(Batches);
    Ground.Collection(Meters);
    Ground.Collection(Messages);
    Ground.Collection(Images);
}
What might be causing this issue and how can I improve the loading time?
Thanks, Don
I solved this issue by invoking Ground.Collection(Collection) after the template has loaded and everything is rendered. iron router's waitOn was causing my app to get stuck and be unusable while ground:db was moving the data to the localstorage.
Hope this helps you as a fast fix!
@fermuch , where did you place the Ground? In Template.myTemplate.rendered ?
Or did you put it in your router ?
First I used it on startup. Now I moved it to a rendered callback. It's working great if I place it on rendered.
thanks. I'll give that a try.
Appreciate the help. Don
@fermuch , if is in rendered, does that me it is re-grounded every time the template renders? Or is GroundDB smart enough to not re-ground something that is already grounded? I'm just concerned there may be a performance hit if we are constantly re-grounding every time the data changes and causes the template to re-render. What is the impact on the data itself? I assume previous data in local storage is overwritten each time it re-grounds?
I'm looking for a best practice.
Thanks Don
@doubletaketech In short I'm currently working on ground db to improve it in several areas.
At the moment grounddb caches the data - for now all subscriptions will load at startup (this is normal Meteor behaviour and in some way it ensures that the data doesn't risk getting polluted by the environment - that said gdb should only request the whole sub if theres an inconsistency)
Regarding the startup performance - You can control the clean up manually https://github.com/GroundMeteor/db#additional-api
Doing it manually or not at all means that you can start subscriptions later if the collection already contains data (you have to do this manually at the moment)
Theres a lot of things that will be improved in grounddb also regarding the new subscription pattern in blaze components - theres no eta, its ready when ready - for now you have to handle things manually.
Another thing - on changes the collection is stored into localstorage - but it allows you to do bulk updates and caches the data on last change / its throttled. Localstorage is not the optimal storage but its the most reliable and supported. So how often will ground db cache the data? At updates (eg. at startup subscription)
I'm noticing this as well. I have a subscription which takes 7 seconds in production. After using groundDb the subscription takes 35 secs. Any ideas on why this is taking so much longer?
Well, localstorage is slow. Very slow. Specially in mobile browsers.