title: Is it mandatory to use "END TRANSACTION" in sqlite
body: <p>In my ios app i am inserting a bulk of data into sqlite using for loop, since insertion was very slow i used </p>
  
  <pre><code> sqlite3_exec(dbh, "BEGIN TRANSACTION", 0, 0, 0); 
  </code></pre>
  
  <p>after using the above statement insertion became very fast,,  now after adding </p>
  
  <p><code>sqlite3_exec(dbh, "END TRANSACTION", 0, 0, 0);</code> insertion has become slow again,, </p>
  
  <p>when i used only <code>sqlite3_exec(dbh, "BEGIN TRANSACTION", 0, 0, 0);</code> insertion was faster,,when i added <code>sqlite3_exec(dbh, "END TRANSACTION", 0, 0, 0);</code>  insertion has become slower,,my question is,,is it mandatory to use "END TRANSACTION" after using "BEGIN TRANSACTION"  ? can i use only  <code>sqlite3_exec(dbh, "BEGIN TRANSACTION", 0, 0, 0);</code>  since insertion is faster with only Begin statement</p>
  
  <p>folowing is my code</p>
  
  <pre><code>BOOL success = TRUE;
      sqlite3_stmt *addStmt;
  
      const char *strStyleInsertQuery = "insert or replace into tbl (id,hole_number,par,distance,delete_flag,course_id) values (?,?,?,?,?,?)";
  
      NSUInteger intCount = [arrHoles count];
      sqlite3_exec(dbh, "BEGIN TRANSACTION", 0, 0, 0);
      for (int i = 0; i &lt; intCount; i++)
      {
          if(sqlite3_prepare_v2(dbh,strStyleInsertQuery, -1, &amp;addStmt, NULL) == SQLITE_OK)
          {
  
              if([[arrHoles objectAtIndex:i] objectForKey:@"handicap"] == nil || [[[arrHoles objectAtIndex:i] objectForKey:@"handicap"] isKindOfClass:[NSNull class]])
                  sqlite3_bind_text(addStmt, 7, [@"" UTF8String], -1, SQLITE_TRANSIENT);
              else
                  sqlite3_bind_text(addStmt, 7, [[NSString stringWithFormat:@"%d",[[[arrHoles objectAtIndex:i] objectForKey:@"handicap"] intValue]] UTF8String], -1, SQLITE_TRANSIENT);
  
          }
          if(SQLITE_DONE != sqlite3_step(addStmt))
          {
              success = FALSE;
              NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(dbh));
          }
          //Reset the add statement.
          sqlite3_reset(addStmt);
      }
      sqlite3_exec(dbh, "END TRANSACTION", 0, 0, 0);   //IS THIS MANDATORY?
  </code></pre>