Merge lp:~stub/launchpad/db-stats into lp:launchpad

Proposed by Stuart Bishop
Status: Merged
Approved by: Stuart Bishop
Approved revision: no longer in the source branch.
Merged at revision: 12794
Proposed branch: lp:~stub/launchpad/db-stats
Merge into: lp:launchpad
Diff against target: 50 lines (+7/-5)
1 file modified
utilities/report-database-stats.py (+7/-5)
To merge this branch: bzr merge lp:~stub/launchpad/db-stats
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+57160@code.launchpad.net

Description of the change

Fix ordering of database bloat report

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utilities/report-database-stats.py'
2--- utilities/report-database-stats.py 2011-03-28 06:14:46 +0000
3+++ utilities/report-database-stats.py 2011-04-11 13:14:47 +0000
4@@ -165,8 +165,9 @@
5 # We only collect these statistics daily, so add some fuzz
6 # to ensure bloat information ends up on the daily reports;
7 # we cannot guarantee the disk utilization statistics occur
8- # exactly 24 hours apart.
9- 'where': get_where_clause(options, fuzz='6 hours'),
10+ # exactly 24 hours apart. Our most recent snapshot could be 1
11+ # day ago, give or take a few hours.
12+ 'where': get_where_clause(options, fuzz='1 day 6 hours'),
13 'bloat': options.bloat,
14 'min_bloat': options.min_bloat,
15 'kind': kind,
16@@ -181,6 +182,7 @@
17 count(*) OVER t AS num_samples,
18 last_value(table_len) OVER t AS table_len,
19 pg_size_pretty(last_value(table_len) OVER t) AS table_size,
20+ last_value(dead_tuple_len + free_space) OVER t AS bloat_len,
21 pg_size_pretty(last_value(dead_tuple_len + free_space) OVER t)
22 AS bloat_size,
23 first_value(dead_tuple_percent + free_percent) OVER t
24@@ -206,7 +208,7 @@
25 WHERE
26 table_len >= %(min_bloat)s
27 AND end_bloat_percent >= %(bloat)s
28- ORDER BY bloat_size DESC
29+ ORDER BY bloat_len DESC
30 """ % params)
31 cur.execute(query, params)
32 bloat_stats = named_fetchall(cur)
33@@ -316,7 +318,7 @@
34 print "== Most Bloated Indexes =="
35 print
36 for bloated_index in index_bloat_stats[:options.limit]:
37- print "%40s || %2d%% || %s of %s" % (
38+ print "%65s || %2d%% || %s of %s" % (
39 bloated_index.sub_name,
40 bloated_index.end_bloat_percent,
41 bloated_index.bloat_size,
42@@ -359,7 +361,7 @@
43 # Bloat decreases are uninteresting, and would need to be in
44 # a separate table sorted in reverse anyway.
45 if bloated_index.delta_bloat_percent > 0:
46- print "%40s || +%4.2f%% || +%s" % (
47+ print "%65s || +%4.2f%% || +%s" % (
48 bloated_index.sub_name,
49 bloated_index.delta_bloat_percent,
50 bloated_index.delta_bloat_size)