获取基本数据库表格、大小和计数统计

The task rake db:stats will print out basic database stats.

./launcher enter app
rake db:stats 

table_name                 | row_estimate | size
---------------------------------------------------
email_logs                 | 4027838      | 611 MB
post_timings               | 9193590      | 388 MB
posts                      | 285127       | 266 MB
post_search_data           | 285127       | 194 MB
topic_views                | 4177774      | 185 MB
optimized_images           | 683840       | 136 MB
topic_users                | 1450648      | 134 MB
topic_links                | 647432       | 111 MB
unsubscribe_keys           | 905960       | 109 MB
incoming_links             | 1828047      | 107 MB
notifications              | 404150       | 91 MB
topics                     | 142508       | 80 MB
topic_search_data          | 142913       | 72 MB
topic_link_clicks          | 1159317      | 70 MB
directory_items            | 701916       | 51 MB
user_actions               | 629565       | 46 MB
users                      | 116988       | 35 MB
user_visits                | 519360       | 26 MB
post_stats                 | 284715       | 19 MB
topic_allowed_users        | 245966       | 14 MB
post_revisions             | 17369        | 14 MB
uploads                    | 52288        | 14 MB
email_tokens               | 119044       | 13 MB
user_options               | 116988       | 12 MB
scheduler_stats            | 101012       | 12 MB
user_search_data           | 116988       | 12 MB
draft_sequences            | 219310       | 11 MB
user_stats                 | 116988       | 11 MB
group_users                | 144370       | 9632 kB
user_emails                | 116988       | 9104 kB
github_user_infos          | 113617       | 7808 kB
user_profiles              | 116988       | 7464 kB
user_avatars               | 116988       | 7144 kB
user_profile_views         | 129138       | 7000 kB
user_archived_messages     | 106711       | 6280 kB
post_actions               | 81849        | 6136 kB
user_badges                | 78525        | 5240 kB
user_auth_tokens           | 20396        | 5096 kB
user_histories             | 46810        | 4552 kB
top_topics                 | 18387        | 3136 kB
etc... 

You can use this to provide us some extra information about the size of your db when asking for help that may be related to db size.

12 个赞

how can we know (whole) database size?
While all db tables are there, whole DB size hasn’t been shown/told in this anywhere.

这并非 Discourse 特有,你可以运行以下命令来查看整个数据库的大小:

./launcher enter app
rails db
SELECT pg_size_pretty(pg_database_size(current_database()));
2 个赞

谢谢。
我通过该命令成功查看了数据库大小。

但之后,为了体面地退出 Rails 控制台,我按了 Ctrl+Z。
结果它却弹出了这条消息让我有些惊讶:

discourse-> 
^Z[1]+  Stopped                 rails db

然后,当我按 exit 退出时,它提示“存在已停止的作业”,随后返回到正常的白色提示符,于是我关闭了窗口。

我对这两条消息感到有些担心。我该怎么办?

编辑:我的网站目前似乎运行正常。