Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

sqlite transactions taking time

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??

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: sqlite transactions taking time

Which of these is taking the time?  Is there any need to open and close the database every time?

Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: sqlite transactions taking time

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??

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: sqlite transactions taking time

[ Edited ]

Hi @

 

 

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.

Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: sqlite transactions taking time

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..

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: sqlite transactions taking time