# Unusually high CPU usage

**URL:** https://meta.discourse.org/t/unusually-high-cpu-usage/394651
**Category:** Self-hosting
**Created:** [January 29, 2026, 1:27pm UTC](https://meta.discourse.org/t/unusually-high-cpu-usage/394651 "2026-01-29T13:27:05Z")
**Posts on this page:** 1
**Showing post:** 28

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [February 9, 2026, 7:36pm UTC](https://meta.discourse.org/t/unusually-high-cpu-usage/394651/28 "2026-02-09T19:36:49Z")

</div>

> [@char](#):
>
> I´d hypothesize having not enough memory: queries go into swap.

(not swap, but they’re reading from disk)

this fits with my earlier observations:

> [@supermathie](#):
>
> there’s only around 6GB taken up by applications. There’s a lot of _reading_ happening, which at a guess I’d say (along with sidekiq being busy) maybe postgres is doing a lot of reading of old data from disk, maybe to do some stats jobs. If the database doesn’t fit in RAM, it’s potentially going to do a lot of reading if that older data is being accessed.

> [@char](#):
>
> `pg_total_relation_size`

Note this is the size of the relation _and indexes_. Compare with `pg_relation_size`.

> [@char](#):
>
> ```plaintext
> 2501 | 2026-02-07 11:25:01.028892+00 | active | IO | DataFileRead | UPDATE posts +
> | | | | | SET percent_rank = X.percent_rank +
> | | | | | FROM ( +
> | | | | | SELECT posts.id, Y.percent_rank +
> | | | | | FROM posts
> 
> ```

This is from `ScoreCalculator`, part of `PeriodicalUpdates`.

> [@char](#):
>
> many statistics recalculations are hogging up resources (ie. Jobs::DestroyOldDeletionStubs - 419 seconds; Jobs::AboutStats - 472 seconds; Jobs::EnsureDbConsistency 2083 seconds; Jobs::TopRefreshOlder - 2727 seconds

This is your finding that needs to be solved. By comparison, here on meta `Jobs::EnsureDbConsistency` takes \<2min and `Jobs::TopRefreshOlder` takes \<10s:

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/8/8/3884a79b3020e0acb625db81899c57653f929322.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/8/a/28a5a05618e85d676fa2717b70aa2342ecab2a38.png)

Postgres needs more memory. Give it as much as you can.

You might also see benefit from a `VACUUM ANALYZE` or `VACUUM ANALYZE FULL`. Doing the first never hurts.

I’d probably do, in order:

- `vacuum analyze`
- pause sidekiq then `vacuum analyze full` (this freezes the tables to rewrite them fully, may incur some failures while it runs)
- more memory to postgres

---

_[View the full topic](https://meta.discourse.org/t/unusually-high-cpu-usage/394651)._
