No, it won't download complete database. This is only additional table served as a flag, increased its value every time there are an update on table data.But how do you get only the updated records? I don't understand. Your solution seems only valid for a complete database to download.
Most of the time spent is in the exchange between the client and the server, not in selecting the records. I suppose that your DB engine (I don't know at all Firebird) is able to run a Select query on 20000 records in a few ms. So your solution will probably take more time than querying directly the updated records, and you can have an inconsistency between the ID and the retrieved records (imagine that you have your UpdateFlag=4, and while the device is getting back this information and reissuing a query, new records are added to the table so the new UpdateFlag=5; on next use, the device will do 2 useless queries because it has already the new records).No, it won't download complete database. This is only additional table served as a flag, increased its value every time there are an update on table data.
Table data still have a timestamp field.
Instead off query directly to table data for every newer records, app will try to query this additional table first, caused it will faster since it is only contain 1 record. If this additional table indicated that there are an update on table data, then app will query these update on table data.
Yes it could run it without a problem, so no additional table thenMost of the time spent is in the exchange between the client and the server, not in selecting the records. I suppose that your DB engine (I don't know at all Firebird) is able to run a Select query on 20000 records in a few ms.
I am still just curios about why we dont see an improvement in multiple requests to the server. There is either syncronisation happening at the client sending out requests (highly unlikely), the server is not creating concurrent connections, or when you receive your data, your JobDone thread is busy, so it happens there (maybe its the try catch).
The only way to know is to log the times of the events i.e. Log time when each request is sent out, log it when entering in the job done sub, also log when your JobDone sub exits.
incendio said:post: 289586, member: 61321"]Thanks for your suggestion. Considering that there is a potential corrupted sqlite database in devices, which is a more big problems, it seem that this the only solution.
oSQL.ExecNonQuery("ATTACH DATABASE ':memory:' AS DBTEMP")
oSQL.ExecNonQuery("CREATE TABLE DBTEMP.temptable (Field1 interger, Field2 integer, Field3 String, Field4 String, Field5 String, Field6 String, Field7 String)")
SQL.AddNonQueryToBatch("insert into DBTEMP.temptable(Field1,Field2,Field3,Field4,Field5,Field6,Field7) values(?,?,?,?,?,?,?)",Array As Object(ValI1,ValI2,ValC1,ValC2,ValC3,ValC4,ValI3))
oSQL.ExecNonQuery("INSERT INTO table (Field1,Field2,Field3,Field4,Field5,Field6,Field7) SELECT
Field1,Field2,Field3,Field4,Field5,Field6,Field7) FROM DBTEMP.temptable")
Use a memory based database then write it to the main DB and ensure you have Write Ahead Logging enabled.
B4X:oSQL.ExecNonQuery("INSERT INTO table (Field1,Field2,Field3,Field4,Field5,Field6,Field7) SELECT Field1,Field2,Field3,Field4,Field5,Field6,Field7) FROM DBTEMP.temptable")
Here is the logYes, but it is not clear from that patter what event is logged when.
For JobDone, just put a Log("Starting Job Done:" & DateTime.Time(DateTime.now)) after Sub JobDone and
put a Log("Finishing Job Done:" & DateTime.Time(DateTime.now)) before End Sub.
Is Job done execution time depend on number of data send with http request?JobDone is executed on the main thread. So the events will always run one after another.
However the http requests are handled in parallel.
How to check Write Ahead Logging on my sqlite already enabled?
Should this code execute within transaction?
oCursor = oSQL.Exec
Query("PRAGMA journal_mode")
oSQL.ExecNonQuery("PRAGMA journal_mode = WAL")
Yes, so this is what I wanted @incendio to check. And now I have to agree with him that the Http Requests do not seem to be returning in parallel (it may be possible they are sent in parallel, but somewhere they are definitely being queued up).JobDone is executed on the main thread. So the events will always run one after another.
However the http requests are handled in parallel.