# Database seems inexplicably large

**URL:** https://meta.discourse.org/t/database-seems-inexplicably-large/77872
**Category:** Self-hosting
**Tags:** hosting
**Created:** [January 12, 2018, 7:28pm UTC](https://meta.discourse.org/t/database-seems-inexplicably-large/77872 "2018-01-12T19:28:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 12, 2018, 7:28pm UTC](https://meta.discourse.org/t/database-seems-inexplicably-large/77872/1 "2018-01-12T19:28:36Z")

</div>

tl;dr: it looks like there are about 10GB of data reported by `rake db:stats`, but postgres\_data is taking up 18GB. Does it seem likely that there are 8GB of indexes taking up the rest of the space, or is there some kind of cleanup that needs to be done?

### Longer version of the same question

The postgres data directory is 18GB. A dump of the database is about 5GB.

```plaintext
var/discourse# du -hs shared/data/postgres_data/
18G shared/data/postgres_data/

```

Here’s what `rake db:stats` reveals. I truncated the rows reported in kB (about 10GB).

| table\_name | row\_estimate | size |
| --- | --- | --- |
| post\_timings | 49643076 | 3011 MB |
| posts | 2289502 | 990 MB |
| user\_actions | 5506773 | 915 MB |
| post\_search\_data | 2136003 | 875 MB |
| email\_logs | 2934363 | 717 MB |
| topic\_views | 3498593 | 507 MB |
| topic\_users | 3714046 | 448 MB |
| post\_stats | 1894296 | 319 MB |
| notifications | 1178136 | 296 MB |
| post\_replies | 1077331 | 127 MB |
| topics | 146814 | 107 MB |
| post\_actions | 456903 | 63 MB |
| draft\_sequences | 671770 | 54 MB |
| post\_revisions | 74596 | 51 MB |
| user\_profile\_views | 465818 | 49 MB |
| topic\_search\_data | 124471 | 46 MB |
| topic\_links | 160437 | 33 MB |
| scheduler\_stats | 168878 | 29 MB |
| uploads | 82100 | 22 MB |
| post\_custom\_fields | 35255 | 22 MB |
| top\_topics | 106478 | 21 MB |
| unsubscribe\_keys | 109936 | 19 MB |
| optimized\_images | 67107 | 18 MB |
| user\_histories | 77643 | 13 MB |
| topic\_link\_clicks | 124501 | 12 MB |

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 12, 2018, 7:43pm UTC](https://meta.discourse.org/t/database-seems-inexplicably-large/77872/2 "2018-01-12T19:43:35Z")

</div>

You may have a restore schema with tables, try list those with `psql`.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 12, 2018, 7:54pm UTC](https://meta.discourse.org/t/database-seems-inexplicably-large/77872/3 "2018-01-12T19:54:09Z")

</div>

Thanks. Is this what I’m looking for? I don’t think I see a restore schema, but I’m not quite sure what I’m looking for.

```
                List of relations

```

| Schema | Name | Type | Owner |
| --- | --- | --- | --- |
| public | api\_keys | table | discourse |
| public | application\_requests | table | discourse |
| public | ar\_internal\_metadata | table | discourse |
| public | badge\_groupings | table | discourse |
| public | badge\_types | table | discourse |
| public | badges | table | discourse |
| public | categories | table | discourse |
| public | categories\_web\_hooks | table | discourse |
| public | category\_custom\_fields | table | discourse |
| public | category\_featured\_topics | table | discourse |
| public | category\_featured\_users | table | discourse |
| public | category\_groups | table | discourse |
| public | category\_search\_data | table | discourse |
| public | category\_tag\_groups | table | discourse |
| public | category\_tags | table | discourse |
| public | category\_users | table | discourse |
| public | child\_themes | table | discourse |
| public | color\_scheme\_colors | table | discourse |
| public | color\_schemes | table | discourse |
| public | custom\_emojis | table | discourse |
| public | developers | table | discourse |
| public | directory\_items | table | discourse |
| public | draft\_sequences | table | discourse |
| public | drafts | table | discourse |
| public | email\_change\_requests | table | discourse |
| public | email\_logs | table | discourse |
| public | email\_tokens | table | discourse |
| public | embeddable\_hosts | table | discourse |
| public | facebook\_user\_infos | table | discourse |
| public | github\_user\_infos | table | discourse |
| public | given\_daily\_likes | table | discourse |
| public | google\_user\_infos | table | discourse |
| public | group\_archived\_messages | table | discourse |
| public | group\_custom\_fields | table | discourse |
| public | group\_histories | table | discourse |
| public | group\_mentions | table | discourse |
| public | group\_users | table | discourse |
| public | groups | table | discourse |
| public | groups\_web\_hooks | table | discourse |
| public | incoming\_domains | table | discourse |
| public | incoming\_emails | table | discourse |
| public | incoming\_links | table | discourse |
| public | incoming\_referers | table | discourse |
| public | instagram\_user\_infos | table | discourse |
| public | invited\_groups | table | discourse |
| public | invites | table | discourse |
| public | message\_bus | table | discourse |
| public | muted\_users | table | discourse |
| public | notifications | table | discourse |
| public | oauth2\_user\_infos | table | discourse |
| public | onceoff\_logs | table | discourse |
| public | optimized\_images | table | discourse |
| public | permalinks | table | discourse |
| public | plugin\_store\_rows | table | discourse |
| public | post\_action\_types | table | discourse |
| public | post\_actions | table | discourse |
| public | post\_custom\_fields | table | discourse |
| public | post\_details | table | discourse |
| public | post\_replies | table | discourse |
| public | post\_revisions | table | discourse |
| public | post\_search\_data | table | discourse |
| public | post\_stats | table | discourse |
| public | post\_timings | table | discourse |
| public | post\_uploads | table | discourse |
| public | posts | table | discourse |
| public | queued\_posts | table | discourse |
| public | quoted\_posts | table | discourse |
| public | remote\_themes | table | discourse |
| public | scheduler\_stats | table | discourse |
| public | schema\_migration\_details | table | discourse |
| public | schema\_migrations | table | discourse |
| public | screened\_emails | table | discourse |
| public | screened\_ip\_addresses | table | discourse |
| public | screened\_urls | table | discourse |
| public | search\_logs | table | discourse |
| public | single\_sign\_on\_records | table | discourse |
| public | site\_settings | table | discourse |
| public | stylesheet\_cache | table | discourse |
| public | tag\_group\_memberships | table | discourse |
| public | tag\_groups | table | discourse |
| public | tag\_search\_data | table | discourse |
| public | tag\_users | table | discourse |
| public | tags | table | discourse |
| public | theme\_fields | table | discourse |
| public | themes | table | discourse |
| public | top\_topics | table | discourse |
| public | topic\_allowed\_groups | table | discourse |
| public | topic\_allowed\_users | table | discourse |
| public | topic\_custom\_fields | table | discourse |
| public | topic\_embeds | table | discourse |
| public | topic\_invites | table | discourse |
| public | topic\_link\_clicks | table | discourse |
| public | topic\_links | table | discourse |
| public | topic\_search\_data | table | discourse |
| public | topic\_tags | table | discourse |
| public | topic\_timers | table | discourse |
| public | topic\_users | table | discourse |
| public | topic\_views | table | discourse |
| public | topics | table | discourse |
| public | translation\_overrides | table | discourse |
| public | twitter\_user\_infos | table | discourse |
| public | unsubscribe\_keys | table | discourse |
| public | uploads | table | discourse |
| public | user\_actions | table | discourse |
| public | user\_api\_keys | table | discourse |
| public | user\_archived\_messages | table | discourse |
| public | user\_auth\_token\_logs | table | discourse |
| public | user\_auth\_tokens | table | discourse |
| public | user\_avatars | table | discourse |
| public | user\_badges | table | discourse |
| public | user\_custom\_fields | table | discourse |
| public | user\_emails | table | discourse |
| public | user\_exports | table | discourse |
| public | user\_field\_options | table | discourse |
| public | user\_fields | table | discourse |
| public | user\_histories | table | discourse |
| public | user\_open\_ids | table | discourse |
| public | user\_options | table | discourse |
| public | user\_profile\_views | table | discourse |
| public | user\_profiles | table | discourse |
| public | user\_search\_data | table | discourse |
| public | user\_stats | table | discourse |
| public | user\_visits | table | discourse |
| public | user\_warnings | table | discourse |
| public | users | table | discourse |
| public | versions | table | discourse |
| public | watched\_words | table | discourse |
| public | web\_hook\_event\_types | table | discourse |
| public | web\_hook\_event\_types\_hooks | table | discourse |
| public | web\_hook\_events | table | discourse |
| public | web\_hooks | table | discourse |
| (131 rows) | | | |

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 13, 2018, 5:14am UTC](https://meta.discourse.org/t/database-seems-inexplicably-large/77872/4 "2018-01-13T05:14:36Z")

</div>

Is that giant inline table really necessary?

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [November 8, 2020, 6:06am UTC](https://meta.discourse.org/t/database-seems-inexplicably-large/77872/5 "2020-11-08T06:06:34Z")

</div>

Our Discourse `post-timings` table size is about 17GB. Is this normal?

| table\_name | row\_estimate | table\_size | index\_size | total\_size |
| --- | --- | --- | --- | --- |
| post\_timings | 120967448 | 6676 MB | 10 GB | 17 GB |
| posts | 3616224 | 2413 MB | 3219 MB | 5632 MB |
| user\_actions | 15159571 | 1215 MB | 3699 MB | 4914 MB |
| post\_search\_data | 3531969 | 3756 MB | 1031 MB | 4787 MB |
| notifications | 2241273 | 687 MB | 824 MB | 1510 MB |
| topic\_views | 7696258 | 369 MB | 1110 MB | 1478 MB |
| post\_actions | 3475097 | 350 MB | 618 MB | 968 MB |
| topic\_users | 3343623 | 365 MB | 257 MB | 622 MB |
| user\_auth\_token\_logs | 1123545 | 410 MB | 110 MB | 520 MB |
| post\_stats | 2779471 | 354 MB | 155 MB | 509 MB |
| incoming\_links | 3154654 | 219 MB | 251 MB | 469 MB |
| topics | 64301 | 142 MB | 286 MB | 429 MB |
| post\_replies | 2327812 | 220 MB | 120 MB | 340 MB |
| user\_visits | 289994 | 17 MB | 229 MB | 246 MB |
| stylesheet\_cache | 4605 | 204 MB | 840 kB | 205 MB |
| top\_topics | 40202 | 19 MB | 148 MB | 167 MB |
| user\_profile\_views | 593591 | 61 MB | 97 MB | 158 MB |
| post\_revisions | 102832 | 87 MB | 8072 kB | 95 MB |

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 8, 2020, 3:31pm UTC](https://meta.discourse.org/t/database-seems-inexplicably-large/77872/6 "2020-11-08T15:31:37Z")

</div>

Yes, that is the largest table in any active Discourse site, with one of the indexes on it taking most of the space.

We will rollout an update to PostgreSQL this year that will make it take half that space, so stay tuned 😉
