tdb_sql: Collect stats on wasted UPDATEs in data prop storage.

This will give us better data on which tables will prefer to
SELECT and INSERT and which will prefer to optimistically UPDATE.
This commit is contained in:
Neil Williams
2012-08-20 00:09:03 -07:00
parent 0ca1ceb110
commit d8fa5e9099
2 changed files with 19 additions and 1 deletions

View File

@@ -508,6 +508,8 @@ def set_data(table, thing_id, **vals):
i = table.insert(values = dict(thing_id = thing_id))
i.execute(*inserts)
return len(inserts)
def incr_data_prop(table, type_id, thing_id, prop, amount):
t = table
transactions.add_engine(t.bind)

View File

@@ -257,7 +257,11 @@ class DataThing(object):
data_props[k] = v
if data_props:
self._set_data(self._type_id, self._id, **data_props)
useless_updates = self._set_data(self._type_id,
self._id,
**data_props)
else:
useless_updates = 0
if thing_props:
self._set_props(self._type_id, self._id, **thing_props)
@@ -271,6 +275,18 @@ class DataThing(object):
self._cache_myself()
thing_or_rel = "thing" if self._type_prefix == "t" else "rel"
if useless_updates:
g.stats.simple_event("%s.useless_updates.%s" % (thing_or_rel,
self._type_name),
useless_updates)
if data_props:
g.stats.simple_event("%s.data_props.%s" % (thing_or_rel,
self._type_name),
len(data_props))
@classmethod
def _load_multi(cls, need):
need = tup(need)