Efficient DB calls to update recycler view

10
February 11, 2019, at 09:10 AM

I have a MYSQL database holding my data. It consists of various texts and a couple of image urls for each row. I am loading each of these rows onto a RecyclerView.

I am confused on how to do this efficiently. Assuming I have a million rows, it would be insane to fetch them all at once. Its not like user can see all the data in one go.

But if I say fetch 10 rows at a time, keep count of last row and fetch the next 10 rows via another dB call after some scrolling, I find that insane too. So many dB calls which gets worse with multi users.

This dB is getting updated meanwhile.. Meaning I actually can't use the method of keeping count on the last row cos that means I am missing out on the latest inserts into the dB.

What's the usual solution here? It seems like a common situation like how twitter and instagram handles its scrolling updates but I am struggling to find references online.

I am trying to solve this without having to switch to a nosql database. Appreciate any advice. Thanks.

Answer 1

You may use Pagination with RecyclerView

Here are some good resources for that

pagination-with-recyclerview

https://stackoverflow.com/a/45909144/5559590

READ ALSO
MySQL: Calculate width date in column

MySQL: Calculate width date in column

I want to define a cron that freqently delete specific data from a MySQL column if date in date_added column is older than 60 days, but don't find any infomation if MySQL supports calculation width dateIs that possible and if yes how to do?

16
column count doesn't match the value count at row 1_database insert error

column count doesn't match the value count at row 1_database insert error

Been working on this for a whileFor some reason even though I have enough values and columns, I get "column count doesn't match value count at row 1" error

41
cannot get id from ajax

cannot get id from ajax

I can't get the id from the js file, I don't know if the js code or the php code is wrongCan someone help? problem seems to be from index

11
Inserting 2 rows instead of one: angular and php

Inserting 2 rows instead of one: angular and php

I am working with angular 6 and phpWhen i add an entity whith my application, i find that the backend is inserting 2 rows in the table instead of one

34