본문 바로가기

프로그래밍

Sqlite Insert 속도 문제시

반응형
using System; using Mono.Data.Sqlite;  public class Example {      static void Main()      {         string cs = "URI=file:test.db";                          using (SqliteConnection con = new SqliteConnection(cs))          {             con.Open();              using(SqliteTransaction tr = con.BeginTransaction())             {                 using (SqliteCommand cmd = con.CreateCommand())                 {                      cmd.Transaction = tr;                     cmd.CommandText = "DROP TABLE IF EXISTS Friends";                     cmd.ExecuteNonQuery();                     cmd.CommandText = @"CREATE TABLE Friends(Id INTEGER PRIMARY KEY,                                          Name TEXT)";                     cmd.ExecuteNonQuery();                     cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Tom')";                     cmd.ExecuteNonQuery();                     cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Rebecca')";                     cmd.ExecuteNonQuery();                     cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Jim')";                     cmd.ExecuteNonQuery();                     cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Robert')";                     cmd.ExecuteNonQuery();                     cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Julian')";                     cmd.ExecuteNonQuery();                     cmd.CommandText = "INSERT INTO Friends(Name) VALUES ('Jane')";                     cmd.ExecuteNonQuery();                 }                  tr.Commit();             }              con.Close();         }     } }

 

 

BeginTransaction 안해주면 속도가 엄청느리다.

반응형

'프로그래밍' 카테고리의 다른 글

TCP 유령세션  (0) 2020.06.25
이미지 화면 출력 비율 계산  (0) 2015.09.25