# Get basic database table, size and count statistics

**URL:** https://meta.discourse.org/t/get-basic-database-table-size-and-count-statistics/68783
**Category:** Sysadmins
**Tags:** how-to
**Created:** [August 25, 2017, 2:28pm UTC](https://meta.discourse.org/t/get-basic-database-table-size-and-count-statistics/68783 "2017-08-25T14:28:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 25, 2017, 2:28pm UTC](https://meta.discourse.org/t/get-basic-database-table-size-and-count-statistics/68783/1 "2017-08-25T14:28:05Z")

</div>

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

```plaintext
./launcher enter app
rake db:stats 

```

```plaintext

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.

---

<div class="post-metadata">

### Author: ![BobbyZopfan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bobbyzopfan/32/149374_2.png) [@BobbyZopfan](https://meta.discourse.org/u/BobbyZopfan)
#### Post date: [June 17, 2019, 3:08am UTC](https://meta.discourse.org/t/get-basic-database-table-size-and-count-statistics/68783/8 "2019-06-17T03:08:56Z")

</div>

> [@sam](#):
>
> database

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

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [July 3, 2019, 10:15am UTC](https://meta.discourse.org/t/get-basic-database-table-size-and-count-statistics/68783/9 "2019-07-03T10:15:18Z")

</div>

This is not Discourse specific, but you can run this to know the size of the whole database

```plaintext
./launcher enter app
rails db
SELECT pg_size_pretty(pg_database_size(current_database()));

```

---

<div class="post-metadata">

### Author: ![BobbyZopfan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bobbyzopfan/32/149374_2.png) [@BobbyZopfan](https://meta.discourse.org/u/BobbyZopfan)
#### Post date: [July 3, 2019, 10:49am UTC](https://meta.discourse.org/t/get-basic-database-table-size-and-count-statistics/68783/10 "2019-07-03T10:49:56Z")

</div>

Thank you.  
I saw the db size successfully by this command.

But after that, in order to come out of Rails console decently, I pressed Ctrl+ z.  
And it rather surprised me with this msg:

```plaintext
^Z[1]+ Stopped rails db

```

And then, when I pressed `exit` to come out, it said `There are Stopped jobs` and came to normal white prompt and thus I closed the window.

I’m rather afraid of these 2 msgs. Should I ?

Edit: My website seems to be working fine at this moment.
