Skip to content
Browse files

Add per-table statistics to postgresql stats

  • Loading branch information...
1 parent 3cc7e11 commit 469745bd2f811a45b898fb86034efc7eafc879fe @dcramer dcramer committed Feb 15, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 postgresql.py
View
17 postgresql.py
@@ -111,6 +111,16 @@ def get_data(self):
COALESCE(sum(n_tup_del),0) AS deleted, \
COALESCE(sum(n_tup_hot_upd),0) AS hotupdated \
FROM pg_stat_user_tables"
+ table_tuple_access_query = """SELECT schemaname, relname, COALESCE(seq_tup_read,0) AS seqread,
+ COALESCE(idx_tup_fetch,0) AS idxfetch,
+ COALESCE(n_tup_ins,0) AS inserted,
+ COALESCE(n_tup_upd,0) AS updated,
+ COALESCE(n_tup_del,0) AS deleted,
+ COALESCE(n_tup_hot_upd,0) AS hotupdated
+ FROM pg_stat_user_tables
+ WHERE schemaname = 'public'"""
+
+
data['query_time'] = exc(conn, query_time_query, 'type', 'coalesce')
datnames = exc(conn, datname_list_query)[0]
@@ -149,6 +159,13 @@ def get_data(self):
for key in row.keys():
data['scans'][db][key] = row[key]
+ results = exc(conn2, table_tuple_access_query)
+ for row in results:
+ row_result = data['table_stats'][db][row['schemaname']][row['relname']]
+ for key in (k for k in row.keys() if k not in ('schemaname', 'relname')):
+ row_result[key] = row[key]
+
+
try:
slony_db = self.config['postgresql']['slony_db']
slony_node_string = self.config['postgresql']['slony_node_string']

0 comments on commit 469745b

Please sign in to comment.
Something went wrong with that request. Please try again.