我在Windows 7上使用ServerStack.OrmLite 4.0。 我使用OrmLite創建了一個表,並在Sqlite文件中插入了大約100行數據。 Db.Select()的時間花了大約1分鐘。當我將數據庫更改爲mysql時,它立即返回結果。我也嘗試使用另一個GUI軟件訪問sqlite數據庫,並嘗試執行一些sql語句,他們都運行良好。有人有任何線索嗎?用於SQLite的ServiceStack.Ormlite,運行速度非常慢
更新,代碼:
static void Main(string[] args)
{
string dbName = "testdb.sqlite";
var path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (!System.IO.File.Exists(path + "/" + dbName))
{
System.IO.File.Create(path + "/" + dbName).Dispose();
}
var dbFacory = new OrmLiteConnectionFactory("Data Source=./testdb.sqlite;Version=3;UTF8Encoding=True;", SqliteDialect.Provider);
//var dbFacory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFacory.OpenDbConnection();
db.DropAndCreateTable<TestTable>();
db.DropAndCreateTable<BasicPersonnelInfo>();
Console.WriteLine("Starts at : {0}", DateTime.Now.Second);
for (int i = 0; i < 100; i++)
{
db.Insert<TestTable>(new TestTable { TestField = i.ToString()});
db.Insert<BasicPersonnelInfo>(new BasicPersonnelInfo { Test3 = i.ToString()});
}
Console.WriteLine("Inserting Completed;");
Console.WriteLine("Select at : {0}", DateTime.Now.Second);
db.Select<BasicPersonnelInfo>();
Console.WriteLine("Ends at : {0}", DateTime.Now.Second);
Console.WriteLine("Prese anykey to quit!");
Console.ReadKey();
}
我正在將SQLite保存到磁盤。謝謝,我試過在內存中使用SQLite數據庫。它仍然很慢(花費大約相同的時間,就像我從內存中的SQLite數據庫中進行選擇一樣),因此文件權限已被分解。我不知道發生了什麼事。 – gnaix
@ gnaix如果你可以創建一個獨立的問題並將其發佈到github存儲庫,那麼它絕對不應該在1分鐘左右的時間內使用SQLite插入100行,我可以看看。 – mythz
[進程監視器](https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx)可以幫助您。 – labilbe