I have a database with over 800000 records in one table.
I want to load this tables data into a list icon.
I currently take each row returned from a query and form a string with columnName + chr(10) then add this to the list icon.
Works very well but takes a long time
Is there any trick or tip to load the ListIcon quickly or should I look towards breaking the table data into bite sized chunks loading each as they are needed?
Regards
CD
Speed Up Listicon Loading?
-
- Addict
- Posts: 1309
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Speed Up Listicon Loading?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Re: Speed Up Listicon Loading?
Definitely yes for 800000 items. That's so much data for a poor little ListIconGadget().collectordave wrote:should I look towards breaking the table data into bite sized chunks loading each as they are needed?
For smaller amounts of data and for Windows only, you can turn drawing of the gadget off while filling. Try this example below (that only uses 100000 items) with the "NoRedraw" variable set to 0 at first, and then set to 1 on the second run. My results were 43 seconds with 0, and only 5 seconds with 1.
Code: Select all
NoRedraw=0
OpenWindow(0,320,256,640,480,"ListIcon",#PB_Window_SystemMenu)
ListIconGadget(0,20,20,600,450,"Items",600)
If NoRedraw=1
SendMessage_(GadgetID(0),#WM_SETREDRAW,0,0)
EndIf
start.q=ElapsedMilliseconds()
For i=1 To 100000
AddGadgetItem(0,-1,Str(i))
Next
time.q=ElapsedMilliseconds()-start
If NoRedraw=1
SendMessage_(GadgetID(0),#WM_SETREDRAW,1,0)
EndIf
Debug "Took "+Str(time)+" ms to fill"
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
-
- Addict
- Posts: 1309
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: Speed Up Listicon Loading?
Thanks for the reply BarryG
Unfortunately I am writing for cross platform so no windows only.
I have been experimenting and 1000 record chunks seems to give a good trade off between speed and usefull data.
Cheers
CD
Unfortunately I am writing for cross platform so no windows only.
I have been experimenting and 1000 record chunks seems to give a good trade off between speed and usefull data.
Cheers
CD
Last edited by collectordave on Sat Aug 03, 2019 2:51 pm, edited 1 time in total.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Re: Speed Up Listicon Loading?
Yes, you don't want to load an entire database into a gadget! Use the scroll events to replace the currently viewed list. 10 or 20 rows. That is fast.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
-
- User
- Posts: 53
- Joined: Sat May 14, 2011 10:39 am
Re: Speed Up Listicon Loading?
Instead of SendMessage_(GadgetID(0),#WM_SETREDRAW,0,0) you can use HideGadget(0, 1)
Code: Select all
NoRedraw=1
OpenWindow(0,320,256,640,480,"ListIcon",#PB_Window_SystemMenu)
ListIconGadget(0,20,20,600,450,"Items",600)
If NoRedraw=1
HideGadget(0, 1)
EndIf
start.q=ElapsedMilliseconds()
For i=1 To 100000
AddGadgetItem(0,-1,Str(i))
Next
time.q=ElapsedMilliseconds()-start
If NoRedraw=1
HideGadget(0, 0)
EndIf
Debug "Took "+Str(time)+" ms to fill"
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Re: Speed Up Listicon Loading?
Won't the user wonder where their window item went?Sirius-2337 wrote:you can use HideGadget(0, 1)
Re: Speed Up Listicon Loading?
HideGadget() is a good alternative to #WM_SETREDRAW and cross platform as well
Use it to load the first 100 - 1000 items then use a thread to load the rest
Use it to load the first 100 - 1000 items then use a thread to load the rest
Egypt my love
Re: Speed Up Listicon Loading?
@collectordave,
Have you tried ListEX by Thorsten1867?
On my MacBook it loads 800,000 lines in less than 5 seconds.
If you are interested try the link below:
viewtopic.php?p=533673#p533673
Have you tried ListEX by Thorsten1867?
On my MacBook it loads 800,000 lines in less than 5 seconds.
If you are interested try the link below:
viewtopic.php?p=533673#p533673
DE AA EB
-
- Addict
- Posts: 1309
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: Speed Up Listicon Loading?
Cracked it with the GridEX module.
Loading 20 rows at a time.
Posted a quick DB viewer to demonstrate viewtopic.php?f=12&t=73329
Thanks for the replies.
CD
Loading 20 rows at a time.
Posted a quick DB viewer to demonstrate viewtopic.php?f=12&t=73329
Thanks for the replies.
CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.