# “重置主题计数器”耗时很长并且会崩溃

**URL:** https://meta.discourse.org/t/resetting-topic-counters-takes-forever-and-crashes/316158
**Category:** Migration
**Created:** [2024年七月13日 08:35 UTC](https://meta.discourse.org/t/resetting-topic-counters-takes-forever-and-crashes/316158 "2024-07-13T08:35:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lega4](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lega4/32/430878_2.png) [@lega4](https://meta.discourse.org/u/lega4)
#### Post date: [2024年七月13日 08:35 UTC](https://meta.discourse.org/t/resetting-topic-counters-takes-forever-and-crashes/316158/1 "2024-07-13T08:35:19Z")

</div>

我正要完成迁移（约 50k 用户、约 300k 帖子、约 100k 私信）。

虽然数据迁移工作大致顺利，但脚本在“重置主题计数器”步骤卡住了。上次甚至因为“PostgreSQL 空间不足”（我有约 500 GB 可用空间）而崩溃。

这个步骤能否分成更小的块，甚至完全跳过？从代码来看，我感觉这些计数器在发帖等操作时会被重新设置。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2024年七月13日 10:21 UTC](https://meta.discourse.org/t/resetting-topic-counters-takes-forever-and-crashes/316158/2 "2024-07-13T10:21:12Z")

</div>

我认为应该增加 PostgreSQL 的内存设置。“可用空间”可能指的是某个数据结构中的空间，而不是磁盘空间。也许可以搜索一些关于 PostgreSQL 调优的内容。
