# 用户个人资料页面加载缓慢

**URL:** <https://meta.discourse.org/t/slow-page-loads-on-user-profiles/155165>\
**Category:** Feature\
**Created:** [2020年六月17日 20:56 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:** 2

<div class="post-metadata">

**Author:** ![Ghan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ghan/32/177964_2.png) [@Ghan](https://meta.discourse.org/u/Ghan)\
**Post date:** [2020年六月19日 20:53 UTC](https://meta.discourse.org/t/slow-page-loads-on-user-profiles/155165/2 "2020-06-19T20:53:36Z")

</div>

在此附上供参考。我已为数据库添加了 4 个索引，性能得到了显著提升，不过我认为仍有优化空间。以下是我添加的内容：

```plaintext
CREATE INDEX index_topic_links_on_clicks_and_created ON public.topic_links USING btree (clicks, created_at);
CREATE INDEX index_posts_on_like_count_and_created ON public.posts USING btree (like_count, created_at);
CREATE INDEX index_topic_links_on_clicks_and_created_desc ON public.topic_links USING btree (clicks DESC, created_at DESC);
CREATE INDEX index_posts_on_like_count_and_created_desc ON public.posts USING btree (like_count DESC, created_at DESC, user_id) WHERE deleted_at IS NULL AND post_number > 1 AND (post_type = ANY ('{1,2,3,4}'::integer[]));

```

---

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