# Slow Page Loads on User Profiles

**URL:** https://meta.discourse.org/t/slow-page-loads-on-user-profiles/155165
**Category:** Feature
**Created:** [June 17, 2020, 8:56pm UTC](https://meta.discourse.org/t/slow-page-loads-on-user-profiles/155165 "2020-06-17T20:56:15Z")
**Posts on this page:** 1
**Showing post:** 6

<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: [June 25, 2020, 5:41pm UTC](https://meta.discourse.org/t/slow-page-loads-on-user-profiles/155165/6 "2020-06-25T17:41:38Z")

</div>

Let me check the plans for those queries in Meta.

Queries are quite fast on Meta, but I can see how they can perform badly on under powered databases. We are using ActiveRecord and the code is quite clean, but the generated SQL is quite messy.

Doing the SQL manually we can make the query use existing indexes and optimize it a lot:

Before

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

After

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/e/3e26ba7ac0f37e0a05447cfb39783c1f472d2cae.png)

In the optimized query we only retrieve posts from the user, limiting the loop of posts for the join happening too late.

So I believe we can get better performance without adding index overhead.

---

_[View the full topic](https://meta.discourse.org/t/slow-page-loads-on-user-profiles/155165)._
