# Update took quite long due to Vacuum

**URL:** <https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203>\
**Category:** Self-hosting\
**Created:** [23 Gennaio 2017, 11:37am UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203 "2017-01-23T11:37:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsoutar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rsoutar/32/121260_2.png) [@rsoutar](https://meta.discourse.org/u/rsoutar)\
**Post date:** [23 Gennaio 2017, 11:37am UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/1 "2017-01-23T11:37:16Z")

</div>

Hi, I was running an update using `./launcher rebuild app` But it stuck at

```
156:M 23 Jan 10:19:31.078 * 10 changes in 300 seconds. Saving...
156:M 23 Jan 10:19:31.081 * Background saving started by pid 3150
3150:C 23 Jan 10:19:31.655 * DB saved on disk
3150:C 23 Jan 10:19:31.657 * RDB: 26 MB of memory used by copy-on-write
156:M 23 Jan 10:19:31.714 * Background saving terminated with success
2017-01-23 11:23:52 UTC [3137-57] discourse@discourse WARNING: skipping "sql_languages" --- only table or database owner can vacuum it
2017-01-23 11:23:52 UTC [3137-58] discourse@discourse WARNING: skipping "sql_packages" --- only table or database owner can vacuum it
2017-01-23 11:23:52 UTC [3137-59] discourse@discourse WARNING: skipping "sql_parts" --- only table or database owner can vacuum it
2017-01-23 11:23:52 UTC [3137-60] discourse@discourse WARNING: skipping "sql_sizing" --- only table or database owner can vacuum it
2017-01-23 11:23:52 UTC [3137-61] discourse@discourse WARNING: skipping "sql_sizing_profiles" --- only table or database owner can vacuum it
WARNING: skipping "sql_languages" --- only table or database owner can vacuum it
WARNING: skipping "sql_packages" --- only table or database owner can vacuum it
WARNING: skipping "sql_parts" --- only table or database owner can vacuum it
WARNING: skipping "sql_sizing" --- only table or database owner can vacuum it
WARNING: skipping "sql_sizing_profiles" --- only table or database owner can vacuum it

```

Using htop I saw that it running a VACUUM for an hour or so.

 ![](https://global.discourse-cdn.com/meta/original/3X/9/6/965efc5337a9d0e1082576310bde17eefeffb19a.png)

Any ideas? Thank you

---

<div class="post-metadata">

**Author:** ![rsoutar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rsoutar/32/121260_2.png) [@rsoutar](https://meta.discourse.org/u/rsoutar)\
**Post date:** [23 Gennaio 2017, 1:30pm UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/2 "2017-01-23T13:30:30Z")

</div>

The update has complete after 3 hours.

---

<div class="post-metadata">

**Author:** ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)\
**Post date:** [23 Gennaio 2017, 10:10pm UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/3 "2017-01-23T22:10:31Z")

</div>

Discourse occasionally runs a VACUUM on the database during migrations to make sure space is being reclaimed (see [the `db:migrate` job in db.rake](https://github.com/discourse/discourse/blob/master/lib/tasks/db.rake#L7)). You can disable this behaviour by setting [the `vacuum_db_days` site setting to 0](https://github.com/discourse/discourse/blob/master/lib/tasks/db.rake#L12).

---

<div class="post-metadata">

**Author:** ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)\
**Post date:** [24 Gennaio 2017, 2:47am UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/4 "2017-01-24T02:47:41Z")

</div>

Hmm actually `VACUUM ANALYZE` can be run against a live DB. I think we should move it into a background process when the app is running rather than run it during a rebuild?

---

<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:** [25 Gennaio 2017, 3:36pm UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/5 "2017-01-25T15:36:19Z")

</div>

Maybe have weekly schedule trigger it if it is overdue?

---

<div class="post-metadata">

**Author:** ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)\
**Post date:** [25 Gennaio 2017, 10:55pm UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/6 "2017-01-25T22:55:45Z")

</div>

That’s what autovacuum is supposed to be doing. Perhaps we just need to tweak the thresholds for that a bit?

---

<div class="post-metadata">

**Author:** ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)\
**Post date:** [3 Febbraio 2017, 9:53am UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/7 "2017-02-03T09:53:18Z")

</div>

Ahh good point. In that case, I don’t see a point in us running `VACUUM ANALYZE` from the app and have a PR to remove it.

[https://github.com/discourse/discourse/pull/4687](https://github.com/discourse/discourse/pull/4687)

If we need to tweak autovacuum, we should configure it from the template in [discourse\_docker](https://github.com/discourse/discourse_docker).

---

<div class="post-metadata">

**Author:** ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)\
**Post date:** [20 Febbraio 2017, 1:09am UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/8 "2017-02-20T01:09:07Z")

</div>

PR has been merged 🙂

---

<div class="post-metadata">

**Author:** ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)\
**Post date:** [20 Febbraio 2017, 1:09am UTC](https://meta.discourse.org/t/update-took-quite-long-due-to-vacuum/56203/9 "2017-02-20T01:09:09Z")

</div>


