0
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 毫秒)。抱歉耽误了时间...

4

1 回答 1

-2

如果您使用的是 SQL 服务器,您可以使用 SQL 语句中的“显示估计执行计划”来查找是否有一个部分比另一部分占用更多资源。例如,如果您使用选择查询的结果来填充表,则具有复杂连接的选择可能会减慢速度。

于 2013-09-05T10:11:40.270 回答