Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is writing into an in-memory SQLITE database so much slower than using an ArrayList?
    primarykey
    data
    text
    <p>I maintain an application that is collecting a lot of information and is storing these information in an ArrayList.</p> <p>In detail this ArrayList is defined as <code>ArrayList&lt;FileInformation&gt;</code> which has some member like:</p> <pre><code>private File mFile; private Long mSize; private int mCount; private Long mFilteredSize; private int mFilteredCount; private int mNumberOfFilters; </code></pre> <p>etc.</p> <p>This approach is working but is not very flexible when I would like to introduce some new functionality. It also has some limitations in terms of memory usage and scale-ability. Because of this I did some tests if a database is the better approach. From the flexibility there is no question, but somehow I'm not able to make it running fast enough to become a real alternative.</p> <p>Right now the database has just one table like this:</p> <pre><code>CREATE TABLE ExtContent ( "path" TEXT not null, "folderpath" TEXT not null, "filename" TEXT, "extention" TEXT, "size" NUMERIC, "filedate" NUMERIC, "isfolder" INTEGER not null, "firstfound" NUMERIC not null, "lastfound" NUMERIC not null, "filtered" INTEGER not null ); </code></pre> <p>The performance issue is immense. Collecting and writing <strong>~14000</strong> items takes <strong>~3mins</strong>! when writing into the database and just <strong>4-5secs</strong> if written into the <code>ArrayList</code>. Creating the database in-memory does not make a big difference.</p> <p>As my experience in terms of SQLITE is rather limited, I started by creating the entries via the <code>android.database.sqlite.SQLiteDatabase.insert</code> methode.</p> <p>As there was no meaningful difference between a file based and a in-memory database, I guess using <code>BEGIN TRANSACTION</code> and <code>COMMIT TRANSACTION</code> will not make any difference.</p> <p>Is there some way to optimize this behavior? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload