# Discourse 优化 PostgreSQL 状态表

**URL:** <https://www.isharkfly.com/t/discourse-postgresql/16903>\
**Category:** Discourse\
**Tags:** discourse\
**Created:** [February 11, 2025, 3:30am UTC](https://www.isharkfly.com/t/discourse-postgresql/16903 "2025-02-11T03:30:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hex](https://www.isharkfly.com/user_avatar/www.isharkfly.com/hex/32/21953_2.png) [@hex](https://www.isharkfly.com/u/hex)\
**Post date:** [February 11, 2025, 3:30am UTC](https://www.isharkfly.com/t/discourse-postgresql/16903/1 "2025-02-11T03:30:00Z")

</div>

当对 Discourse 更新数据库后，新的 PostgreSQL 数据库没有 statistics 表。

你可以使用下面的命令来生成 statistics 表。

```auto
cd /var/discourse
./launcher enter app
su postgres
psql
\connect discourse
VACUUM VERBOSE ANALYZE;
\q
exit
exit

```

当然，你可以可以在 SSH 到服务器上直接运行下面的命令：

```auto
/var/discourse/launcher run app "echo 'vacuum verbose analyze;' | su postgres -c 'psql discourse'"

```

建议使用单一命令行进行执行。

整体的执行时长应该小于 1 分钟。
