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

BlackBerry® OS Smartphones

Reply
Highlighted
Developer
Posts: 49
Registered: ‎06-02-2009
My Device: Curve8530, Curve8900, Storm9500
My Carrier: Airtel, vodaphone, Wifi
Accepted Solution

Sqlite insert performance issue on real device

I have upgraded OS of my curve8900 device to 5.0 and developing an application which using sqlite database. application need to synch data from server. so it make http connection, get xmldata and parse it. when I am trying to insert around 300 record on empty table of sqlite database everything is working fine on simulator and performance is very good. but when application move on real device insert operation is taking lots of time to insert record on database. Database is on sdcard. 1 record in taking around 2,3 second on real device. so total execution time is more than 600 second (10 min). which is defintly very large.

 

Table is having  8 column only and all are integer and text type. i have search for batch execution command but not found. I do not know how to increrase the performance on real device.

 

Please help me.

 

 

Contributor
Posts: 14
Registered: ‎11-11-2010
My Device: Not Specified

Re: Sqlite insert performance issue on real device

Try doing all your inserts in one transaction:

 

Database.beginTransaction()

//your insert statements

Database.commitTransaction() 

 

This should improve the performance, however might still be not fast enough...

Developer
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: Sqlite insert performance issue on real device

hey rakesh did u find any solution for increasing performance of inserting? Please share with me.. its hard to fix.. please..

Developer
Posts: 49
Registered: ‎06-02-2009
My Device: Curve8530, Curve8900, Storm9500
My Carrier: Airtel, vodaphone, Wifi

Re: Sqlite insert performance issue on real device

Yes I have found the solution.

When I am inserting the records inside  Java Thread then performance is very slow...........

Solutions
insert the record into table after acquiring the event lock. You will get at least 10 to 15 time faster response.

synchronized (UiApplication.getEventLock()){
      // call your java method to insert record into sql lite database 

 }          

Please use beginTransaction() and commitTransaction() method in your insert record method as well

 

Remember : when you acquire the event lock then GUI will lock. So do not acquire the event lock for long time. acquire it and release it after performing insertion of around 500 records.

Developer
Posts: 125
Registered: ‎08-11-2011
My Device: Blackberry Smartphone 9780
My Carrier: -

Re: Sqlite insert performance issue on real device

This not work for me, i already having 1 sec delay in a simple insert... Smiley Sad

---------------------------------------------------------------------

My good english is beceause i dont speak english
Developer
Posts: 49
Registered: ‎06-02-2009
My Device: Curve8530, Curve8900, Storm9500
My Carrier: Airtel, vodaphone, Wifi

Re: Sqlite insert performance issue on real device

Please explain what problem you are facing

is performance not increasing after acquiring the EventLock OR

you are getting any exception.

also check, your code should be like this

 

synchronized (UiApplication.getEventLock()){

       insertRecord()      // method call

 }          

void insertRecord() {

         beginTransaction()

           - insert,  update or delete "multiple" records into database

         commitTransaction()

}

 

Developer
Posts: 125
Registered: ‎08-11-2011
My Device: Blackberry Smartphone 9780
My Carrier: -

Re: Sqlite insert performance issue on real device

Ok, thanks.

 

But, i am trying to optimize only 1 statement, a simple insert !

 

synchronized (UiApplication.getEventLock()){			ManCustomer.addCustomer(objC);					
}      

 

public static void addCustomer(Customer objC){
SimpleSortingVector vector = new SimpleSortingVector();
try {		
Statement st = sqliteDB.createStatement(
"INSERT INTO customer(cusId,cusName,cusLName, cusAddress,cusEmail,cusGender)" +"VALUES ("+objC.getId()+"," +
"'"+objC.getName()+"',"
"'"+objC.getLName()+"',"
"'"+objC.getAddress()+"',"
"'"+objC.getEmail()+"'," +
"'"+objC.getGender()+"')");	
			    
st.prepare();
st.execute();  
}catch ( Exception e ) {         
System.err.println(e.getMessage());
e.printStackTrace();
}

 And this delay between 1 & 2 seconds  Smiley Frustrated, with or without begin and commit transaction.

 

And this is the table :

 

Statement st = d.createStatement( "CREATE TABLE 'customer' ( " +
            								  "'cusId' integer identifier, " +
            								  "'cusName' TEXT , " +
            								  "'cusLName' TEXT , " +
            								  "'cusAddress' TEXT , " +
            								  "'cusEmail' TEXT , " +
            								  "'cusGender' TEXT)" );     

Have you seen something that I can optimize ?

---------------------------------------------------------------------

My good english is beceause i dont speak english
Contributor
Posts: 22
Registered: ‎10-05-2012
My Device: 9800
My Carrier: 0

Re: Sqlite insert performance issue on real device

[ Edited ]

Hi ,

 

I am also using same way to what ever (rakeshsoni) mention above code,

but it is taking long time to taking inserting and selecting datas it's around 5000 to 8000 records are there,

it is taking 1 min to 2 min operations,

 

please help me how to incrase profomance of this