html5sql.js在安卓蜂窝和ICS中的插入速度非常慢

html5sql.js inserting is very slow with Android Honeycomb and ICS

本文关键字:插入 速度 非常 ICS js html5sql      更新时间:2023-09-26

我正在使用html5sql javascript库(html5sql.js)通过Phonegap加快对Android上HTML5数据库的多次插入。安卓2.X的速度似乎很快(1秒内1000行),但安卓3.X和4.X的速度很慢(几分钟后1000行)。有人知道解决办法吗?

我的代码片段:

sqlStatements = 'INSERT INTO table ("id","data") VALUES("' + id + '", "' + data + '"); INSERT INTO ... ' // 1 thousand inserts 
html5sql.openDatabase(
         "dbase",
         "dbase",
         3*1024*1024);
html5sql.process(
            //This is the text data from the SQL file you retrieved
            sqlStatements,
            function(){
                // After all statements are processed this function will be called.
                console.log("success ");
            },
            function(error){
                // Handle any errors here
                console.log("error " + error);
            }
        );

尝试在第一个sql查询之前运行"PRAGMA synchronous=OFF;PRAGMA count_changes=OFF;PRAGMA journal_mode=MEMORY;PRAGMAtemp_store=MEMORY;"