Which will increase my performance or which has faster performance for the following scenario phonegap sqllite db?
Scenario : I have multiple insert statements around 1000 statements.
Approach : 1. Having one transaction [db.transaction] for all the insert statements
db.transaction(function(tx){
data.forEach(function(dataItem) {
tx.executeSql("INSERT INTO test (id, name) VALUES (?,?)", [dataItem.id, dataItem.name]});
}, errorInsertingSectorTable, successInsertSector);}
or 2. for each insert statement having seperate db.transaction
db.transaction(function(tx){
data.forEach(function(dataItem) {
dbExecution.databaseVar.transaction(function(tx) {
tx.executeSql("INSERT INTO test (id, name) VALUES (?,?)", [dataItem.id, dataItem.name]});
});}, error, success);}
Which approach has fast performance or have a less overhead for the phonegap app and the best approach? Please help us clarify.