Android Question Large Database

Enthousiastic

Active Member
Licensed User
Hello , i have a database .db format made by sqlite having 11.000 records . I use Table class module , to display it and all are OK .
The problem is that is slow in loading even in an 8core Samsung tablet.
Any idea if there is a method made it faster ? Th database is 8MB and i cannot send you because of size limitation.


Many thanks Enthousiastic
 

Mahares

Well Known Member
Licensed User
If Erel sees this thread he will advise you that it is not at all practical to try to display 11000 records at once.
1. Break up the data by using WHERE clauses to display only pertinent data.
2. In your SQL statement, request only the needed columns. Do not use all of them.
3. Indexing table by some columns will help, although many indexed fields can slow it down.
4. As a last resort use: SQL1.ExecQueryAsync(.......
 

Troberg

Well-Known Member
Licensed User
Well sometimes you have to display lots of data at once. Sometimes, it's possible to do a "load on demand" to speed things up, sometimes (such as displaying data in maps), you just have to read it all in one chunk.

That said, all the normal database optimizations should work.

I wouldn't say that 11000 records is a large database, though. I have databases with 20 million records (although, not on a mobile device), and even those are not considered large by database standards. This makes me suspect that the performance problem is not in the database, but in the display. Try timing just the database operations, to see if the problem is really there.
 

Peter Simpson

Expert
Licensed User
I had the exact same problem with the Table Class @Enthousiastic, what I did to speed up the population of tables apart from using Limit in the query was the following.

Move the following lines directly into the Table Class, this does speed up the population by quiet a lot. Just experimenting by moving table settings lines directly into the Table Class, I found that helped a lot.
B4X:
'Move these lines
    Table1.HeaderColor = Colors.Blue
    Table1.HeaderTextColor = Colors.Yellow
    Table1.TextColor = Colors.Blue
    Table1.TableColor = Colors.Red
    Table1.RowHeight = 50dip
    Table1.RowColor1 = Colors.RGB(244,164,96)
    Table1.RowColor2 = Colors.RGB(255, 153, 255)
    Table1.AllowSelection = False
I may also have moved the following into the table class as well.
B4X:
    Table1.MultiSelect = False
    Table1.SortColumn = False
    Table1.SingleLine = False
Admittedly I've turned the Table Class into a library as I personally prefer to use it that way.

Enjoy...
 

Enthousiastic

Active Member
Licensed User
I had the exact same problem with the Table Class @Enthousiastic, what I did to speed up the population of tables apart from using Limit in the query was the following.

Move the following lines directly into the Table Class, this does speed up the population by quiet a lot. Just experimenting by moving table settings lines directly into the Table Class, I found that helped a lot.
B4X:
'Move these lines
    Table1.HeaderColor = Colors.Blue
    Table1.HeaderTextColor = Colors.Yellow
    Table1.TextColor = Colors.Blue
    Table1.TableColor = Colors.Red
    Table1.RowHeight = 50dip
    Table1.RowColor1 = Colors.RGB(244,164,96)
    Table1.RowColor2 = Colors.RGB(255, 153, 255)
    Table1.AllowSelection = False
I may also have moved the following into the table class as well.
B4X:
    Table1.MultiSelect = False
    Table1.SortColumn = False
    Table1.SingleLine = False
Admittedly I've turned the Table Class into a library as I personally prefer to use it that way.

Enjoy...
 

Enthousiastic

Active Member
Licensed User
I had the exact same problem with the Table Class @Enthousiastic, what I did to speed up the population of tables apart from using Limit in the query was the following.

Move the following lines directly into the Table Class, this does speed up the population by quiet a lot. Just experimenting by moving table settings lines directly into the Table Class, I found that helped a lot.
B4X:
'Move these lines
    Table1.HeaderColor = Colors.Blue
    Table1.HeaderTextColor = Colors.Yellow
    Table1.TextColor = Colors.Blue
    Table1.TableColor = Colors.Red
    Table1.RowHeight = 50dip
    Table1.RowColor1 = Colors.RGB(244,164,96)
    Table1.RowColor2 = Colors.RGB(255, 153, 255)
    Table1.AllowSelection = False
I may also have moved the following into the table class as well.
B4X:
    Table1.MultiSelect = False
    Table1.SortColumn = False
    Table1.SingleLine = False
Admittedly I've turned the Table Class into a library as I personally prefer to use it that way.

Enjoy...
Sorry i don't understand the module i use is the following .bas .Where can i put the above lines ?
 

Attachments

Top