I have a database that holds Posts. At a future point, my database may hold a very large number of Posts. I am confused as to what to do, as I cannot decide between the few options that I've thought of so far:
1) Load all Posts at once and store them into an Posts[] array, and just show all posts on the TableView that displays them.
2) Load 10 Posts at once and display those 10 at a time, then implement a function that allows the user to scroll and to load 10 more at a time. These 10 values that are loaded will then be added to the TableView.
Now, option #1 seems simple and attractive, as it is what I currently have set up. However, I am not sure if it would be problematic or not to constantly load hundreds of posts every time a user opens the page that displays Posts.
Option #2 seems complex, as I have no idea how to only load 10 Posts at once using Firebase. I am using a .childAdded observation to gather the data, and that usually loads all of the Posts. An alternative idea I had that may or may not be useless is loading all Posts into the Posts[] array but only displaying 10 at a time. This option is attractive because users won't have to load every single post every time they view the TableView that contains the posts. I am also hesitant to take this option because I would have to alter my data structure quite a lot. The current set up is:
root/posts/post-id/post-info
In which the post-info node holds information relevant to the post, and does not contain an index, which I have a feeling that option #2 would require.
I'm quite stuck here. What's the best action to take in a situation like this?