0

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.

mtruth
  • 1

1 Answers1

0

You may use Pagination with RecyclerView

Here are some good resources for that

pagination-with-recyclerview

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

Manzurul Hoque Rumi
  • 2,753
  • 4
  • 17
  • 41
  • Thanks. I've seen the thread on pagination which does give a solution. But is this supposed to be normal? I mean it sounds expensive, every time the person scrolls a certain bit which triggers a db call. Or am I over thinking this and its not inefficient like I presume? Is there like a recommended figure, like load 20 cards at a time and not 10? – mtruth Feb 10 '19 at 09:28