My Win JS SQLite 3 application takes too much time to do inserts

194 views Asked by At

Here I am making app of Sqlite3 database in Windows store apps in HTML /java script.

Right now I am using Sqlite3-WinRT component.

Its working fine but I am not getting required performance. Its taking too much time for insertion data. Is there any way to make the insert performance faster with this library?

If this is not possible, can any one can suggest me any other library or component for using sqlite3 in Windows store apps??

Thanks in advance..

2

There are 2 answers

0
chue x On

Transactions have increased performance in C# SQLite3 applications, so they may help you in your Win JS application.

If you look at issue 56 in the SQLite3-WinRT issues list, they show how to use transactions:

SQLite3JS.openAsync(dbPath)
.then(function (db) {
  return db.runAsync('PRAGMA temp_store = MEMORY;');
}).then(function (db) {
  return db.runAsync("BEGIN TRANSACTION;");
});

Some notes:

  • Issue 56 says that the use of the PRAGMA is temporary, and may not be needed in the future. You should test and see if it is needed.
  • The code above just starts the transaction. Obviously, you will still need to add: 1) your inserts, and 2) a call to commit or abort the transaction, for example, db.runAsync("COMMIT TRANSACTION;");
0
user3454923 On

You can try to wrap your insertions in a

"BEGIN TRANSACTION"  

and end it with

"COMMIT TRANSACTION"

, this will certainly improve your insertion (I used same wrapper).

If this doesn't work, you can try to use this component, even if it is in C#, you can use it in WinJS.

There is an article on how to improve your insertions and selection using this compoenent.