Author: tmckay
Date: 2011-12-07 15:25:47 +0000 (Wed, 07 Dec 2011)
New Revision: 5165
Modified:
trunk/mint/python/mint/update.py
Log:
Optimization for statistics. Only write stats to database if one of the
stats values has changed since the last write. This helps in particular
when creation of a QMF console causes a republish event.
Modified: trunk/mint/python/mint/update.py
===================================================================
--- trunk/mint/python/mint/update.py 2011-12-06 20:24:23 UTC (rev 5164)
+++ trunk/mint/python/mint/update.py 2011-12-07 15:25:47 UTC (rev 5165)
@@ -513,6 +513,8 @@
return col, value
def process_statistics(self, obj, update_columns, insert_columns):
+ build_columns = list()
+ saw_change = False
for stat, value in self.qmf_object.getStatistics():
try:
col = obj._class._statistics_by_name[stat.name].sql_column
@@ -532,14 +534,19 @@
#
# XXX This optimization will be obsolete when QMF does it
# instead
-
if value != getattr(obj, col.name):
+ setattr(obj, col.name, value)
update_columns.append(col)
+ saw_change = True
- insert_columns.append(col)
+ # If we do end up seeing a value change, we will
+ # need to insert an entire row so build it up
+ build_columns.append(col)
- setattr(obj, col.name, value)
+ if saw_change:
+ insert_columns.extend(build_columns)
+
def execute_sql(self, cursor, text, args):
try:
cursor.execute(text, args)
Show replies by date