title: Electron.remote.require('sqlite3') query performance 5x slower, callback 500x slower
body: <p>I'm using Electron w/ webpack and try to add <code>sqlite3</code> to the mix. See <a href="https://github.com/pamtbaau/electron-sqlite3" rel="nofollow noreferrer">stripped down test project</a></p>
  
  <p>I came accross two possible solutions.</p>
  
  <ol>
  <li><p>When I <code>require('sqlite3')</code> in <code>index.html</code> and create a global variable referencing the database, I can query the db from within my application using the global variable. Performance is ok.</p>
  
  <p>Issues: Using global variable feels ugly and I cannot seem to configure Karma to use this scenario.</p>
  
  <p>Question: How should I configure Karma (tried both <code>files</code> and <code>customContextFile</code> options) to unit-test this scenario?</p></li>
  <li><p>When I use <code>remote.require('sqlite3')</code> in my application, the database can be opened/created, but performance of queries degrade by factor ~10 and performance of results callback is down ~500x. (I guess it's a memory allocation issue)</p>
  
  <p>Issues: Sqlite is useless performancewise.</p>
  
  <p>Question: Why does this performance degradation occur and how to solve it to use all benefits of sqlite?</p></li>
  </ol>
  
  <p>Btw. When using <code>import { Database } from 'sqlite'</code> with <code>const db = new Database()</code> node-gyp and node-pre-gyp throw issues which I haven't been able to solve.</p>
  
  <p>NB. I have been using <code>sql.js</code> (performance issues) and <code>Lovefield</code> (inflexible IndexedDB store) as alternatives for sqlite3.</p>