# Long loading times for user summary page with slow database

**URL:** <https://meta.discourse.org/t/long-loading-times-for-user-summary-page-with-slow-database/131870>\
**Category:** Self-hosting\
**Tags:** unsupported-install\
**Created:** [25 באוקטובר,‏ 2019,‏ 1:23pm UTC](https://meta.discourse.org/t/long-loading-times-for-user-summary-page-with-slow-database/131870 "2019-10-25T13:23:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![klopsknoedel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klopsknoedel/32/194126_2.png) [@klopsknoedel](https://meta.discourse.org/u/klopsknoedel)\
**Post date:** [25 באוקטובר,‏ 2019,‏ 1:23pm UTC](https://meta.discourse.org/t/long-loading-times-for-user-summary-page-with-slow-database/131870/1 "2019-10-25T13:23:01Z")

</div>

Hi,

we’re facing huge loading times accessing a users summary page. It seems that it takes longer to load the summary the more active a user interacts with our site. Which, yes, seems quite obvious, but the difference in loading times on our site is immense.  
So loading a “new” users (some weeks of activity) summary page takes ~1sec but loading a users page, who has a daily activity for years, takes up to 30-40secs.

So we’ve checked the database and were quite impressed of the table size (including indexes) of `topic_views` which is 62 GB.

Here are our 7 biggest tables:

| relation | total\_size | table\_size | index\_size | reltuples |
| --- | --- | --- | --- | --- |
| topic\_views | 62 GB | 17 GB | 45 GB | 399215000 |
| posts | 27 GB | 22 GB | 5022 MB | 9123860 |
| top\_topics | 15 GB | 708 MB | 15 GB | 1602180 |
| post\_search\_data | 15 GB | 12 GB | 2849 MB | 8181010 |
| incoming\_links | 12 GB | 5330 MB | 6647 MB | 90008900 |
| user\_actions | 3184 MB | 877 MB | 2307 MB | 11872800 |
| topics | 2117 MB | 1035 MB | 1082 MB | 1613070 |

To test this we’ve picked a user’s id of which we know has a huge loading time of the summaries and performed a count with that ID on the `topic_views` table. This query took nearly the same time as the summary of the user took to load. So the _topics viewed_ part is responsible for this delay.

As explained in [earlier topics](https://meta.discourse.org/t/upgrade-fails-while-migrating/121894) we’ve upgraded an old (v1.2.4 + modifications) Discourse based site to v2.4.0-beta.2 and are now running Discourse v2.4.0-beta6. So may there could be some data left over. But we don’t know what can be deleted.

At this point we’re quite unsure what to do or tweak next. Our installation is running completely on azure using an external instance of Azure Database for PostgreSQL and we’ve applied the configuration described in your [postgres.10.template.yml](https://github.com/discourse/discourse_docker/blob/master/templates/postgres.10.template.yml). We don’t even know if the size of the `topic_views` table (espacially the index) is “to big” in relation to the other tables or if it is quite normal.

Any hint, thought or idea is appreciated.

Kind Regards  
Sascha Hofmann

P.S.  
I forgot to mention that because of this we have several 502 Errors (displayed on the site itself, so no nginx errorpage or application gateway) loading `/u/<username>/summary.json`.

---

_[View the full topic](https://meta.discourse.org/t/long-loading-times-for-user-summary-page-with-slow-database/131870)._
