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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Trusted Contributor
ankitagrawal
Posts: 135
Registered: ‎02-15-2012
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??

Please use plain text.
Developer
peter_strange
Posts: 17,722
Registered: ‎07-14-2008

Re: sqlite transactions taking time

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

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 135
Registered: ‎02-15-2012
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??

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011

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.

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 135
Registered: ‎02-15-2012
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..

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011

Re: sqlite transactions taking time

Please use plain text.