disc330 Posted February 5, 2009 Share Posted February 5, 2009 I'm using _GUICtrlListView_AddArray() along with an SQL query to read records and put them into a list but its taking way too long. I'm currently only using 3 records, and its taking about 7 seconds to just perform the _GUICtrlListView_AddArray() function. If anyone knows a faster way, or knows what im doing wrong here please do tell. ( I assume I am doing something VERY wrong because the helpfile example takes just over a second to display 5000 records with 4 columns...) Code: While _SQLite_FetchData ($hQuery, $aRows) = $SQLITE_OK $RowColCount = StringSplit(_ArrayToString($aRows,"|"),"|") For $ii = 0 to $RowColCount[0]-1 $aItems[$i][$ii] = $aRows[$ii] Next $i += 1 WEnd $timer = TimerInit() _GUICtrlListView_AddArray($LTV_SQLTableData,$aItems) MsgBox(0,"",TimerDiff($timer) ) Still learning...I love autoit. :) Link to comment Share on other sites More sharing options...
KaFu Posted February 5, 2009 Share Posted February 5, 2009 Maybe _GUICtrlListView_SetItemCount($LTV_SQLTableData, UBound($aItems) - 1) _GUICtrlListView_AddArray($LTV_SQLTableData,$aItems) will speed up the update? OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
disc330 Posted February 5, 2009 Author Share Posted February 5, 2009 (edited) Mmm..yes. I like the way you think. Ill go try it. thanks EDIT: After testing... Without the line: 7.6 Seconds With the line: 7.4 Seconds... o.O Still far from ideal. I dont understand what it is. Would it help to use the: _GUICtrlListView_BeginUpdate($hListView) _GUICtrlListView_EndUpdate($hListView) functions? I will go try that now actually. Thanks for the help though still. EDIT 2: Nope, still taking way to long. probably because its al done in one update anyway. However, I just noticed that if I keep refreshing the rows, the time it takes to fill the data increases... Also the scroll bar shows that the list is suddenly huge and filled with far too much empty space. Solved: I was looking in the wrong place. Dim $aItems[50000][20] <--- it was showing all the rows empty or not. Edited February 5, 2009 by disc330 Still learning...I love autoit. :) Link to comment Share on other sites More sharing options...
KaFu Posted February 5, 2009 Share Posted February 5, 2009 (edited) Solved: I was looking in the wrong place. Dim $aItems[50000][20] <--- it was showing all the rows empty or not. , that's why it took 7 seconds... Threw together a dynamic example (dirty ) from the help-file, how to dynamically determine the columns and records. Could definitely do some more error checking, but it works under the given circumstances and might be a good start point (only appoint as much memory to the array as needed). expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include<WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Global $iTimer, $hListView, $aItems, $itemcount Global $hQuery, $aRow Global $aNames[1], $aRow[1], $aItems[1][1] ; Create GUI GUICreate("ListView Add Array", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_STATICEDGE, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) $hListView = GUICtrlGetHandle($hListView) _GUICtrlListView_SetUnicodeFormat($hListView, False) _SQLite_Startup() _SQLite_Open(); open :memory: Database _SQLite_Exec(-1, "CREATE TABLE aTest (col_a,col_b,col_c);") For $i = 1 To 5000 _SQLite_Exec(-1, "INSERT INTO aTest(col_a,col_b,col_c) VALUES (" & $i & "," & $i+1 & ","& $i+2 &");") Next GUISetState() _SQLite_Query(-1, "SELECT count(*) FROM aTest;", $hQuery) If _SQLite_FetchData($hQuery, $aRow) <> $SQLITE_OK Then MsgBox(270400, '', "No records were found in the result set...") ReDim $aRow[1] $aRow[0] = 0 EndIf _SQLite_QueryFinalize($hQuery) If $aRow[0] > 0 Then _SQLite_Query(-1, "SELECT * FROM aTest LIMIT 1;", $hQuery) _SQLite_FetchNames($hQuery, $aNames); Read out Column Names _SQLite_QueryFinalize($hQuery) For $i = 1 To UBound($aNames) _GUICtrlListView_AddColumn($hListView, $aNames[$i-1], 100) Next $itemcount = $aRow[0] ReDim $aItems[$itemcount][UBound($aNames)] $i = 0 _SQLite_Query(-1, "SELECT * FROM aTest;", $hQuery) While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK For $y = 0 To UBound($aNames) - 1 $aItems[$i][$y] = $aRow[$y] Next $i += 1 WEnd _SQLite_QueryFinalize($hQuery) _GUICtrlListView_SetItemCount($hListView, UBound($aItems) - 1) $iTimer = TimerInit() _GUICtrlListView_AddArray($hListView, $aItems) MsgBox(4160, "Information", "Load time: " & TimerDiff($iTimer) / 1000 & " seconds") EndIf Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() _SQLite_Close() _SQLite_Shutdown() Edited February 5, 2009 by KaFu DiscGolferPro 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now