Hum, what to do , what to say?
This all comes down to how big something is relative to how big the bucket you are working with!
The problem here is human cost time vs that of hardware time.
I recall when a 10,000 row database was quite large - you had to be carefull.
Now? Well, I am betting that data pull and load takes well under 1 second. And you can elminate some of your loops!
eg:
Code:
Dim strSQL As String = "SELECT ID, HotelName, City, FirstName from Hotels WHERE " & _
"ID <= " & EditText1.Text
B4XTable1.Clear
B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.AddColumn("HotelName", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("City", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("FirstName", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.SetData(DBUtils.ExecuteMemoryTable(sqlite,strSQL,Null,0))
So above will eliminate "your" loop, and use the internal lib code. But then again, I don't know how well DBUtils is optimized.
Not sure - but is there a list data page library handing around some place?
So, right now? Because you have GOBS of memory and processing? Well, 10k rows is approaching crazy, but it runs in a flash. So, I guess we don't care all that much.
At one time? Well, we would call the Town Sherriff , form a posse, and ask you to leave town at sundown for abuse of computers.
So 10k is workable without doing this the right way.
But, as always, this comes down to how big?
Lets assume your table is 100k rows!!!!
(there is always larger tables hiding in some cave somewhere on planet Earth!!)
Well, now, we back to square one. In other words, how big is too big?
So I think 10k or less? You can get away with that crazy big table load. It is "crazy" but we have those resources right now.
But what about 100k rows?
Well, then I would suggest that you build a data pager, and thus avoid the cruelty to computers society getting on your back.
So, yes, I think a data pager - start, end makes the most sense. However, such a data pager can cause issues if the database engine does not support this ability.
FYI: (sqlite does support "limit like : LIMIT [no of rows] OFFSET [row num])
So a data pager could be built here. Then even if your table has 100k rows, then performance would be fantastic.
So just about any approach that pulls only 10 or say 20 rows for the display? You going to save tons of memory and resources. You will trade this against hitting the database more often - that will be more CPU but then again, we have more CPU then we do memory resources right now.
And I 100% accept that your question and point of
"Why not page the data - seems crazy?"
yes, we all agree that's how this should work.
But, given the elephant size memory and processing we have? You can likely get away working with a 10k table.
but, anything much larger? it will come down to how hard you want to press the memory stack on the given device.
Busy these days - but someone here must have built a data pager "thingy".
So, should we call the Society for abuse and mistreatment of computers? Well, perhaps - but if what you have runs ok, then go with what you have, but do keep a eye on these boards and consider some kind of data pager system (but that is human cost + time - something we are all short of!!).
Good luck. I wish I had better advice. But your question + instincts to page the data? yes, a very good idea.
Regards,
Albert D. Kallal
Edmonton, Alberta Canada