using (SQLiteTransaction trans = sql_con.BeginTransaction())
{
commandInsert.Transaction = trans;
commandInsert.Parameters["@One"].Value = "ONE";
commandInsert.Parameters["@Two"].Value = "TWO";
commandInsert.Parameters["@Three"].Value = "THREE";
commandInsert.Parameters["@Four"].Value = "FOUR";
commandInsert.Parameters["@FIVE"].Value = "FIVE";
commandInsert.Parameters["@SIX"].Value = "SIX";
commandInsert.Parameters["@SEVEN"].Value = "SEVEN";
commandInsert.Parameters["@EIGHT"].Value = "EIGHT";
commandInsert.Parameters["@NINE"].Value = "NINE";
commandInsert.Parameters["@TEN"].Value = "TEN";
commandInsert.Parameters["@ELEVEN"].Value = "ELEVEN";
commandInsert.Parameters["@CommentCount"].Value =
commandInsert.Parameters["@NUMBER1"].Value = 5;
commandInsert.Parameters["@NUMBER2"].Value = 6;
commandInsert.Parameters["@NUMBER3"].Value = 8;
commandInsert.ExecuteNonQuery();
trans.Commit();
}
我在事务上使用参数化命令来插入 1300 条记录。我在一个 uniq 列上有一个索引,但即使我删除索引,这仍然需要 10 秒。
这是我的连接字符串:
string ConnectionString =
"Data Source=Data/database.db3;Version=3;Compress=True;Count Changes=off;Journal Mode=off;Pooling=true;" +
"Cache Size=10000;Page Size=4096;Synchronous=off";
我怎样才能加快速度?
编辑 问题已解决...问题在于检测语言不在插入中(这需要 3 毫秒)。抱歉耽误了时间...