# Database size/maintenance

**URL:** https://meta.discourse.org/t/database-size-maintenance/238312
**Category:** Self-hosting
**Created:** [September 7, 2022, 7:29am UTC](https://meta.discourse.org/t/database-size-maintenance/238312 "2022-09-07T07:29:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)
#### Post date: [September 7, 2022, 7:29am UTC](https://meta.discourse.org/t/database-size-maintenance/238312/1 "2022-09-07T07:29:40Z")

</div>

I’m trying to find out if database size used by Discourse is somehow reasonable and if there’s room for optimization. Space used on the disk is currently at 120GB and these are the biggest tables.

```plaintext
              relation | total_size
------------------------------------+------------
 public.post_timings | 64 GB
 public.posts | 8685 MB
 public.user_auth_token_logs | 8664 MB
 public.topic_views | 8105 MB
 public.user_visits | 8027 MB
 public.post_search_data | 3631 MB
 public.user_actions | 2689 MB
 public.notifications | 2355 MB
 public.topic_users | 2290 MB
 public.email_logs | 1524 MB
 public.incoming_links | 1372 MB

```

I just wonder if this is a reasonable split of sizes. Not sure what post\_timings does but I already read in some other threads that it’s taken up by far the most space.

Is there some kind of maintenance on the db that can and should be done manually?

---

<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: [September 7, 2022, 7:55am UTC](https://meta.discourse.org/t/database-size-maintenance/238312/2 "2022-09-07T07:55:23Z")

</div>

Timings is always the largest table, so that checks out.

If you are up to date on your updates, the last PostgreSQL version brings improvements to this area, but there is a small step you got to follow:

> [@PostgreSQL 13 update](https://meta.discourse.org/t/postgresql-13-update/172563):
>
> warning WARNING! If your database is very large, you will need a lot of extra disk space (2x database size) and should be very careful with this upgrade! We’ve just landed changes to upgrade our Docker image to PostgreSQL 13. Any site admins rebuilding Discourse from the command line will be upgraded to PostgreSQL 13 from the previous PostgreSQL 12. Note that if you held back from upgrading when the PostgreSQL 12 update [happened back in May](https://meta.discourse.org/t/postgresql-12-update/151236), you can skip that upgrade and go straight to P…

See “Re-creating the indexes” there.
