# PG12 中索引损坏，如何修复？

**URL:** <https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570>\
**Category:** Self-hosting\
**Created:** [2020 年5 月 25 日 02:45 UTC](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570 "2020-05-25T02:45:43Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

作者： ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)\
发布日期： [2020 年5 月 25 日 04:56 UTC](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570/16 "2020-05-25T04:56:23Z")

</div>

我认为这些是在从 PostgreSQL 10 迁移到 12 时使用的，因为我看到几乎所有遇到索引问题的用户都提到了这些。例如：  
[https://meta.discourse.org/t/postgresql-12-update/151236/208?u=itsbhanusharma](https://meta.discourse.org/t/postgresql-12-update/151236/208?u=itsbhanusharma)

[https://meta.discourse.org/t/postgresql-12-update/151236/237?u=itsbhanusharma](https://meta.discourse.org/t/postgresql-12-update/151236/237?u=itsbhanusharma)

编辑：来源是 PostgreSQL 官方文档

> **[REINDEX](https://www.postgresql.org/docs/12/sql-reindex.html)**
>
> REINDEX REINDEX — rebuild indexes Synopsis REINDEX \[( option \[, ...\] ) \] { INDEX | TABLE | SCHEMA …

> 在这种情况下，推荐的恢复方法是删除无效索引，然后再次尝试执行 `REINDEX CONCURRENTLY`。在处理过程中创建的并发索引，其名称以 `ccnew` 结尾；如果是未能删除的旧索引定义，则以 `ccold` 结尾。可以使用 `DROP INDEX` 删除无效索引，包括无效的 TOAST 索引。

---

_[View the full topic](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570)._
