I wrote the following test in C# to test SqlLite which I hope would simmulate inserting high frequency data in realtime into an sqllite in memory db. The line
Console.WriteLine(sw.ElapsedMilliseconds);
returns 2200 or 2.2 seconds on my machine (nothing to speak of in terms of speed it is just a dual core with 4GB memory running Windows 7 x64.) I was surprised, this seems slow to me for an in memory database doing a bunch of inserts, 3 * 65,000 to be exact. That only comes to ~87,000 inserts a second. Seems slow...
Note that the program is not multithreaded and I don't know if that would make it faster or not.
Console.WriteLine(sw.ElapsedMilliseconds);
returns 2200 or 2.2 seconds on my machine (nothing to speak of in terms of speed it is just a dual core with 4GB memory running Windows 7 x64.) I was surprised, this seems slow to me for an in memory database doing a bunch of inserts, 3 * 65,000 to be exact. That only comes to ~87,000 inserts a second. Seems slow...
Note that the program is not multithreaded and I don't know if that would make it faster or not.
Code:
static void TestInMemory()
{
SQLiteConnection _cnn;
_cnn = new SQLiteConnection("data source=:memory:");
_cnn.Open();
string schema = GetSchema();
string sql = GetSql();
SQLiteCommand mySchemaCommand = new SQLiteCommand(schema, _cnn);
SQLiteCommand mySqlCommand = new SQLiteCommand(sql, _cnn);
mySchemaCommand.ExecuteNonQuery();
var sw = new Stopwatch();
sw.Start();
for(int i = 0; i < 65000; i++)
mySqlCommand.ExecuteNonQuery();
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
Console.ReadLine();
}
static string GetSchema()
{
return @"
CREATE TABLE [Employees] (
[EmpID] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[EmpName] NVARCHAR(128) NOT NULL,
[EmpSalary] FLOAT NOT NULL
);
";
}
static string GetSql()
{
return @"
INSERT INTO Employees (EmpName, EmpSalary) VALUES ('Joe Bloggs', 5000);
INSERT INTO Employees (EmpName, EmpSalary) VALUES ('Tim Jones', 4000);
INSERT INTO Employees (EmpName, EmpSalary) VALUES ('John Smith', 4500);
";
}