from __future__ import print_function import sqlite3 import time cnxn = sqlite3.connect(':memory:') with cnxn: cnxn.execute('CREATE TABLE tbl (col1 PRIMARY KEY, col2)') cnxn.executemany('INSERT INTO tbl (col2) VALUES (?)', zip(range(2000000))) sql_fast = """ UPDATE tbl SET col2 = NULL WHERE col1 = ? """ sql_slow = """ UPDATE tbl SET col2 = NULL WHERE col1 = ? """ half_ids = list(zip(range(1000000))) start_time = time.clock() with cnxn: cnxn.executemany(sql_fast, half_ids) mid_time = time.clock() print('First step: {s}'.format(s=mid_time - start_time)) with cnxn: cnxn.executemany(sql_slow, half_ids) end_time = time.clock() print('Second step: {s}'.format(s=end_time - mid_time))