(SugarOrm) how to improve slow insertion?

919 views Asked by At

I am trying to insert thousand of data from mylist to database ,it take very long time to save each of the data.

Is there any way to improve the save performance ?

 for (int j = 0; j < listPeople.size(); j++) {
                           Person people= listPeople.get(j);
                           people.save();}



Log
11-27 04:15:06.991  10268-10268/com.testall I/Sugar﹕ Person saved : 1
11-27 04:15:07.991  10268-10268/com.testall I/Sugar﹕ Person saved : .......
11-27 04:16:08.991  10268-10268/com.testall I/Sugar﹕ Person saved : 1000
1

There are 1 answers

1
Satya On BEST ANSWER

There's a method named saveInTx which takes in a collection of objects and is faster than saving individual objects. It's available in 1.3