mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user