← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~seif/zeitgeist/improve-big-inserts into lp:zeitgeist

 

Seif Lotfy has proposed merging lp:~seif/zeitgeist/improve-big-inserts into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)


We call self._cursor.connection.commit() in the following method

def insert_events(self, events, sender=None):
		t = time.time()
		m = map(lambda e: self._insert_event_without_error(e, sender), events)
		self._cursor.connection.commit()
		log.debug("Inserted %d events in %fs" % (len(m), time.time()-t))
		return m

however self._insert_event_without_error calls self._insert_event which also calls self._cursor.connection.commit() upon each event insertion which is wrong and makes inserting big sets of items slower
-- 
https://code.launchpad.net/~seif/zeitgeist/improve-big-inserts/+merge/35725
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~seif/zeitgeist/improve-big-inserts into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py	2010-09-16 07:14:37 +0000
+++ _zeitgeist/engine/main.py	2010-09-16 19:42:51 +0000
@@ -97,7 +97,7 @@
 	value, wildcard = parse_wildcard(kind, field, value)
 	return value, negation, wildcard
 
-
+			
 class ZeitgeistEngine:
 	
 	def __init__ (self):
@@ -590,8 +590,6 @@
 					self._actor[event.actor]))
 			return self._cursor.fetchone()[0]
 		
-		self._cursor.connection.commit()
-		
 		return id
 	
 	def _store_payload (self, event):

=== modified file '_zeitgeist/engine/sql.py'
--- _zeitgeist/engine/sql.py	2010-05-28 07:38:51 +0000
+++ _zeitgeist/engine/sql.py	2010-09-16 19:42:51 +0000
@@ -133,7 +133,7 @@
 	conn = sqlite3.connect(file_path)
 	conn.row_factory = sqlite3.Row
 	cursor = conn.cursor(UnicodeCursor)
-	
+
 	# Always assume that temporary memory backed DBs have good schemas
 	if constants.DATABASE_FILE != ":memory:":
 		if _check_core_schema_upgrade (cursor):


Follow ups