11-28-2012 04:45 AM
I am performing some DB transactions in a block, but it is taking more than 2 seconds to complete the transaction. Transactions are as follows:
OPENING DATABASE sqlite
sqlite.beginTransaction();// BEGIN TRANSACTION
INSERT QUERY
INSERT QUERY
INSERT QUERY
INSERT QUERY
sqlite.commitTransaction();// COMMIT TRANSACTION
CLOSING DATABASE sqlite
How can I improve the speed for above DB transactions??
11-28-2012 05:16 AM
Which of these is taking the time? Is there any need to open and close the database every time?
11-28-2012 05:27 AM
The whole operation is taking about 2 seconds to complete. Single operation is taking about 250 ms.
yes, opening and closing is needed. As per App need, I am using synchronized blocks with lock on 1 object and OPENING and CLOSING DATABASE in same synchronized blocks.
I am using this mechanism to avoid concurrent access of database by background threads.
Is there any method to speedup the DB transactions??
11-28-2012 02:22 PM - edited 11-28-2012 02:22 PM
Hi @ankitagrawal,
Consider holding a cache in memory and have one thread which will update the DB.
Even if you won't have the all DB in memory you will still be able to reduce DB I/O and improve performance.
E.
11-28-2012 02:33 PM
Hi maadani,
Thanks for your reply. Please provide me something in detail - how can I implement it?
Or send me snippet to update the DB through thread.
Thanks again..
11-28-2012 03:18 PM
Check out this thread:
Hope that helps,
E.