# PostgreSQL runaway IO

**URL:** https://meta.discourse.org/t/postgresql-runaway-io/91516
**Category:** Self-hosting
**Created:** [July 3, 2018, 9:59pm UTC](https://meta.discourse.org/t/postgresql-runaway-io/91516 "2018-07-03T21:59:01Z")
**Posts on this page:** 1
**Showing post:** 10

<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: [July 4, 2018, 1:21pm UTC](https://meta.discourse.org/t/postgresql-runaway-io/91516/10 "2018-07-04T13:21:03Z")

</div>

> [@JanJoost](#):
>
> Would it be better to break it up in pieces, close this one and open a new one?

Yes. I set `auto close topics post count` to 1024 or 512 when I had an HDD instance.

Also, I completely forgot, but looks like I took an stab at this query 2 years ago:

> [@Post.calculate\_avg\_time() taking up a long time](https://meta.discourse.org/t/post-calculate-avg-time-taking-up-a-long-time/49750/13):
>
> I believe the daily version of the query can be optimized by moving the filter up in the subquery. Before: [kmV3 : Discourse Post.calculate\_avg\_time daily | explain.depesz.com](https://explain.depesz.com/s/kmV3) After: [i3JU : Discourse Post.calculate\_avg\_time daily Optimized | explain.depesz.com](https://explain.depesz.com/s/i3JU) This would not apply to the weekly one, but as you stated the daily one is the bugger. Can you try that and confirm the differences @michaeld ?

---

_[View the full topic](https://meta.discourse.org/t/postgresql-runaway-io/91516)._
