I have a large (long) table of data stored in SQLite - potentially 5m+ entries. I am using the System.Data.SQLite
package to execute my query and read the data into a bespoke in-memory collection structure in the regular ADO.net way.
CODE (F#)
use cnxn = new SQLiteConnection(@"Data Source=C:\Temp\test.db;Version=3;Read Only=True;")
cnxn.Open()
let data = ResizeArray<Data>()
let cmd = new SQLiteCommand(@"SELECT X, Y, Z, AAA FROM Data", cnxn)
let reader = cmd.ExecuteReader()
while reader.Read() do
let d = {X = reader.GetInt32(0); Y = reader.GetInt32(1);
Z = reader.GetInt32(2); AAA = reader.GetDouble(3)}
data.Add(d)
cnxn.Close()
Questions
Is
System.Data.SQLite
the most performant library to be using for the job here? I am only using it because it appears to be the standardIs their a better way to code this up?
Are there any settings/configurations on the database itself that would help this scenario?
Why do I think this should be able to go faster?
My computer has a theoretical read speed of 725 mb/s (SSD). Reading the sqlite above I am reading 40mb in 1s which is an effective actual speed of 40 mb/s.
Another surprising result from profiling shows that about 35% of the time is spent on reader.Read()
[not surprising] and the remainder in GetInt32
and GetDouble()
[very surprising].