Android Question problems with b4a 6.3

billyrudi

Active Member
Licensed User
Longtime User
Hi, i think that there are problems while looping over a cursor with sqllite.... it is slow slow slow.
someone has encountered the same problem?
today 5 seconds
yesterday before new version less then 1 second
regards Paolo

B4X:
Dim Cursor1 As Cursor
    Dim ssell As String
    If lstelencoGiri.IsInitialized = False Then
        Return
    End If
    lstelencoGiri.Clear1

    ssell = "Select min(Esito) Esito, CodiceDestinatario,max(RagioneSociale) RagioneSociale , max(Indirizzo) Via,max(Citta) Citta, max(IDTransazione) IDTransazione  from Viaggi  where IDFoglioDiViaggio = '" & Operazioni.idfoglioviaggio & "' and Filiale = '" & Operazioni.siglaFiliale & "' group by CodiceDestinatario  Order by Ordinamento Asc"
    Cursor1 = Operazioni.SQL1.ExecQuery( ssell)
    Dim ik As Int
    ik = 0
    Dim bpassato As Boolean
    Dim bgiallo As Boolean
    bpassato = False
    Dim colore As Int
    Dim ultimob As Int
    Operazioni.girifatti = 0
    Operazioni.giritotale = Cursor1.RowCount
    For i = 0 To Cursor1.RowCount - 1
        Cursor1.Position = i
        'individuazione tipo colore
    
        If Cursor1.GetString("Esito") = "S" Or  Cursor1.GetString("Esito") = "X" Then    
            colore = Colors.RGB(6,129,35)
            bpassato = True
            bgiallo = True
            ik = i
            Operazioni.girifatti = Operazioni.girifatti +1
        Else
            If Cursor1.GetString("Esito") = Null Then
                colore  = Colors.White
                If  bpassato = False Then
                    bpassato = True
                    ik = i
                End If
                ultimob = i
            Else
               If Cursor1.GetString("Esito") = "I" Then
                    colore = Colors.Yellow
                    bpassato = True
                    bgiallo = True
                    ik = i
                Else
                    colore = Colors.Red
                    bpassato = True
                    bgiallo = True
                    ik = i
                End If
            
             End If
        End If
    
    
        Dim sfondo As Int
        If i Mod 2 = 0 Then
            sfondo = Colors.Black
        Else
         sfondo =    Colors.DarkGray
        End If
        Dim indices As String
        indices = i + 1
        Dim ordinamento As Int
    
        ordinamento = Cursor1.GetInt("CodiceDestinatario")
        Dim ssel, scons, srit As String
        ssel = "Select count(RagioneSociale) tot from Viaggi where TipoServizio = 'C'  and  IDFoglioDiViaggio = '" & Operazioni.idfoglioviaggio & "' and Filiale = '" & Operazioni.siglaFiliale & "' and CodiceDestinatario = '" & Cursor1.GetString("CodiceDestinatario") & "' group by CodiceDestinatario"
        Dim ct As Cursor
        ct  = Operazioni.SQL1.ExecQuery(ssel)
        If ct.RowCount > 0 Then
            ct.Position = 0
            scons = " - N. Cons.: "& ct.GetInt ("tot")
        Else
            scons = " N. Cons.: 0"
        End If
        ct.close
        ssel = "Select count(RagioneSociale) tot from Viaggi where TipoServizio = 'R' and  IDFoglioDiViaggio = '" & Operazioni.idfoglioviaggio & "' and Filiale = '" & Operazioni.siglaFiliale & "' and CodiceDestinatario = '" & Cursor1.GetString("CodiceDestinatario") & "' group by CodiceDestinatario"
    
        ct  = Operazioni.SQL1.ExecQuery(ssel)
        If ct.RowCount > 0 Then
            ct.Position = 0
            srit = " - N. Rit.: "& ct.GetInt ("tot")
        Else
            srit = " - N. Rit.: 0"
        End If
        ct.Close
        lstelencoGiri.Add(CreateListaItem(indices & ") " &  Cursor1.GetString("RagioneSociale")  & CRLF & Cursor1.GetString("Via") & " " & Cursor1.GetString("Citta") & scons & srit, lstelencoGiri.AsView.Width,   35dip,colore,sfondo, Cursor1.GetString("IDTransazione")), 60dip , ordinamento) 
    Next
    Cursor1.Close
 

tigrot

Well-Known Member
Licensed User
Longtime User
Hi/Ciao,
I don't have any issue from 6.3. My app doesn't loop, but Sqllite is responsive. I have not checked the version of SQL library, since the code for this is in it. You can check it and substitute with a older one in case they are different. I'd check this way. Keep the new library, to replace when the tests are finished.

Ciao
Mauro
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Do you use Index for fields in query?
Index will bust SQL query execution over 1000% (depends of number of rows).
 
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
Hi this is my code with a small database to reproduce my problem. Any help will be appreciated.
 

Attachments

  • InfoMobilityEx.zip
    378.9 KB · Views: 170
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
Hi Erel, yes i have made tests in 6.0 and release. i show 64 records in customlistview in 3 seconds!! this only after update to 6.3
i have tested it in some devices and the result is the same.
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
Hi Erel, yes i have made tests in 6.0 and release. i show 64 records in customlistview in 3 seconds!! this only after update to 6.3
i have tested it in some devices and the result is the same.

I assume you have run "Clean Project" after installing v6.30?
 
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
i have run it. Do you have test my project?
Now i'm installing b4x 6.0 in a new computer to try to understand where is the problem!
I'm spending three days finding a solution to this question! :(
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
i have run it. Do you have test my project?
Now i'm installing b4x 6.0 in a new computer to try to understand where is the problem!
I'm spending three days finding a solution to this question! :(

I downloaded your test app but the BottomNavigation library is missing.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Search the forum for it.
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User

I installed it along with java-json.jar.

I ran it on the Android emulator (Nexus 9 with Android 5.1.1) in debug mode and it executes "Sub carica()" in 0.472 seconds from start to finish. It loads 47 items into the list.

I am using B4A v6.30.

  1. Have you deleted the app from your device and let B4a re-install it?
  2. Have you tried rebooting the computer and re-installing B4A v6.30? Maybe when you installed it the last time some of the files were locked? A re-install may solve the problem.
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
One other suggestion. The problem might not be related to SQLite at all. It might have something to do with how the list is loaded or where your database is located.

Try commenting out blocks of code in your routine using:
#IF LOADVIEW
.. Skip this block of code..
#END IF

So you only have the SQLite code that is being executed. Don't try to load the data into your view. See if the speed returns.

I sometimes like to use conditional compilation with "#IF #ELSE #END IF" because I can easily turn it on or off by setting a Conditional Symbol in Build Configurations. There is no messy blocks of comments to uncomment and I can easily reactivate/deactivate LoadView in a second.

I also added a Toast message to the bottom of the Sub so I know how fast it runs. I suggest you do the same.

If the speed still does not return even after skipping all but the SQLite code, it is time to create a test application to isolate the code even more.
Create a test application that loads the data from a test database with no views, timers or events defined. This will give you the raw speed of the database.

Let us know how things turn out. If you want me to test it on other devices in the emulator, I can do that too.
 
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
Hi Widget,
thank you for your interest in my problem.
I think that the question is not how i create the database or how loop over the records or how i use customlistview.
The question is why befoare the 6.3 update the app works correctly and i'm able to load many many records in less than one second and after i'm not able.
I use a dedicated pc with only b4a installed on it with windows 10.
I i can produce some logs to help to understand well the problem please ask me.
The app that i have post in the blog is already a copy and past of some code lines in a new project to show what i'm doing and how.
regards Paolo
 
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
please click in rubrica and in viaggi, the slow step is loading customlistview in viaggi bottom bar.
 
Upvote 0
Top