mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: improve stats provided by rake db:stats
New stats include index size and sort by index + table size Eg: ``` table_name | row_estimate | table_size | index_size | total_size -------------------------------------------------------------------------- topic_views | 18260776 | 796 MB | 2015 MB | 2811 MB post_timings | 15813837 | 668 MB | 1153 MB | 1821 MB posts | 386890 | 1532 MB | 215 MB | 1747 MB post_search_data | 317575 | 580 MB | 162 MB | 742 MB incoming_emails | 34412 | 734 MB | 7160 kB | 741 MB incoming_links | 5169302 | 306 MB | 377 MB | 683 MB email_logs | 5 | 32 kB | 418 MB | 418 MB topic_users | 2410166 | 217 MB | 155 MB | 372 MB user_actions | 1361253 | 101 MB | 266 MB | 366 MB ... ```
This commit is contained in:
parent
e2df331fdb
commit
4c6a0313f2
@ -119,10 +119,12 @@ task 'db:stats' => 'environment' do
|
|||||||
from pg_class
|
from pg_class
|
||||||
where oid = ('public.' || table_name)::regclass
|
where oid = ('public.' || table_name)::regclass
|
||||||
) AS row_estimate,
|
) AS row_estimate,
|
||||||
pg_size_pretty(pg_relation_size(quote_ident(table_name))) size
|
pg_size_pretty(pg_table_size(quote_ident(table_name))) table_size,
|
||||||
|
pg_size_pretty(pg_indexes_size(quote_ident(table_name))) index_size,
|
||||||
|
pg_size_pretty(pg_total_relation_size(quote_ident(table_name))) total_size
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
where table_schema = 'public'
|
where table_schema = 'public'
|
||||||
order by pg_relation_size(quote_ident(table_name)) DESC
|
order by pg_total_relation_size(quote_ident(table_name)) DESC
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
puts
|
puts
|
||||||
|
Loading…
Reference in New Issue
Block a user