title: SQLite .NET performance, how to speed up things?
body: <p>On my system, ~86000 SQLite insertions took up to 20 minutes, means ~70 insertions per second. I have to do millions, how can I speed up it? Calling Open() and Close() on SQLiteConnection object for every line can slow down performance? Can transactions help?</p>
  
  <p>Typical insertion method for a single line:</p>
  
  <pre><code>    public int InsertResultItem(string runTag, int topicId,
          string documentNumber, int rank, double score)
      {
          // Apre la connessione e imposta il comando
          connection.Open();
  
          command.CommandText = "INSERT OR IGNORE INTO Result "
            + "(RunTag, TopicId, DocumentNumber, Rank, Score) " +
              "VALUES (@RunTag, @TopicId, @DocumentNumber, @Rank, @Score)";
  
          // Imposta i parametri
          command.Parameters.AddWithValue("@RunTag", runTag);
          command.Parameters.AddWithValue("@TopicId", topicId);
          command.Parameters.AddWithValue("@DocumentNumber", documentNumber);
          command.Parameters.AddWithValue("@Rank", rank);
          command.Parameters.AddWithValue("@Score", score);
  
          // Ottieni il risultato e chiudi la connessione
          int retval = command.ExecuteNonQuery();
          connection.Close();
  
          return retval;
      }
  </code></pre>
  
  <p>As you can see, insertions are very simple ones.</p>