一个事务有多个查询,或者每个查询都有一个单独的事务,哪个更快?
一个事务包含多个查询:
db.transaction(function (tx){
tx.executeSql( INSERT INTO TEST VALUES ("Halo1" ,"Halo2") , [], win, fail);
tx.executeSql( INSERT INTO TEST VALUES ("Halo3" ,"Halo4") , [], win, fail);
tx.executeSql( INSERT INTO TEST VALUES ("Halo5" ,"Halo6") , [], win, fail);
.
.
.
.
});
每个查询一个事务:
db.transaction(function(tx){
tx.executeSql( INSERT INTO TEST VALUES ("Halo1" ,"Halo2") , [], win, fail);
});
db.transaction(function(tx){
tx.executeSql( INSERT INTO TEST VALUES ("Halo3" ,"Halo4") , [], win, fail);
});
and so on.....
我需要这些信息,因为我必须在一个表中插入许多记录。