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

**URL:** <https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570>\
**Category:** Self-hosting\
**Created:** [2020年五月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:** 5\
**Page:** 3

<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:** [2020年五月29日 19:10 UTC](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570/43 "2020-05-29T19:10:12Z")

</div>

有可能。我认为前面的 `%` 就足够了，但我也可能弄错了。

---

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [2020年五月30日 12:33 UTC](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570/44 "2020-05-30T12:33:45Z")

</div>

> [@itsbhanusharma](#):
>
> 我认为需要 `ilike`。

正确。

例如：

 ![Screen Shot 2020-05-30 at 7.32.59 PM](https://global.discourse-cdn.com/meta/original/3X/b/9/b90b7f5e17016fc8016490008a5b3b0120cc56d4.jpeg)

---

<div class="post-metadata">

**Author:** ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)\
**Post date:** [2020年五月30日 12:57 UTC](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570/45 "2020-05-30T12:57:41Z")

</div>

但是……所有设置都是小写的，所以在查询中直接使用小写是否就不需要 `ilike` 了？

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2020年六月29日 13:12 UTC](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570/46 "2020-06-29T13:12:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2023年一月26日 05:16 UTC](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570/47 "2023-01-26T05:16:35Z")

</div>

好吧，如果这能让任何人感觉好点，我自己也遇到了！

```plaintext
Caused by:
PG::UniqueViolation: ERROR: could not create unique index "index_incoming_referers_on_path_and_incoming_domain_id_c_ccnew2"
DETAIL: Key (path, incoming_domain_id)=(/_, 1169) is duplicated.

```

上面的说明——进入容器，启动 postgres，查询坏数据，按 id 删除它……很有帮助。

[上一頁](https://meta.discourse.org/t/corrupt-indexes-in-pg12-how-do-i-fix/152570.md?page=2)
