2012-03-12 44 views
0

我正在使用html5sql javascript庫(html5sql.js)加速多個插入到Android的Phone5上的HTML5數據庫。 Android 2.X似乎非常快(1秒1000行),但Android 3.X和4.X(幾分鐘內1000行)速度非常慢。有誰知道解決方案?html5sql.js插入是非常緩慢的Android Honeycomb和ICS

我的代碼片斷:

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); 
      } 
     ); 

回答

0

嘗試運行 「PRAGMA同步= OFF; PRAGMA count_changes = OFF; PRAGMA journal_mode = MEMORY; PRAGMA TEMP_STORE = MEMORY;」在第一個sql查詢之前

+0

它沒有幫助 – davidns 2012-03-13 08:41:14

+0

我發現你的提示可以用標準插入方法,例如, tx.executeSql(INSERT INTO ...)但不適用於html5sql.js庫。當然,html5sql.js比tx.executeSql()快得多。 – davidns 2012-03-15 09:04:46