Your C# code is timing the entire loop while appending to a StringBuilder.
This is going to be slower than simply running the SQLite query.  I suggest
trying the following change to get a clearer picture of the time spent
executing the actual query:

        cmd.Prepare();
        var dtStart = Environment.TickCount;
        DbDataReader reader =
cmd.ExecuteReader(CommandBehavior.CloseConnection);
        var dtEnd = Environment.TickCount;

        try
        {
          while (reader.Read())
          {
            sb.AppendFormat("PersonId: {0}\r\n", reader[0]);
          }
        }
        finally
        {
          reader.Close();
        }

Please note that even the above code will show some overhead associated with
using SQLite from managed code; however, it will be less than the original
code.

--
Joe Mistachkin

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to