Reindex
Postgres BTREE index cannot be created if the index entry size exceeds 1/3 (≈2.7KB) of the disk page (8KB), so large text is stored outside the page using the TOAST technique. However, using TOASTed values directly in unique indexes causes performance degradation. Only B-Tree efficiently supports unique constraints, while Hash indexes are unsuitable as they require full value comparison during collisions. Therefore, it's recommended to create a generated column storing MD5 or SHA-256 hash values of large text and apply a unique B-Tree index to that column
Handling unique indexes on large data in PostgreSQL
A month ago, during a release to production, the feature I was working on failed to deploy due to a PostgreSQL restriction. It turned out to be a surprisingly fun and comprehensive learning moment.
https://volodymyrpotiichuk.com/blog/articles/unique-indexes-on-large-data-in-postgres-sql

REINDEX
REINDEX 는 인덱스 테이블에 저장된 데이터를 사용하여 인덱스의 이전 복사본을 대체하여 인덱스를 다시 작성합니다. REINDEX 를 사용하는 몇 가지 시나리오가 있습니다 . 색인이 손상되었으며 더 이상 유효한 데이터가 없습니다. 이론 상으로는 이런 일이 발생하지 않아야하지만 실제로 소프트웨어 버그 나 하드웨어 오류로 인해 색인이 손상 될 수 있습니다. REINDEX 는 복구 방법을 제공합니다.
https://runebook.dev/ko/docs/postgresql/sql-reindex

Seonglae Cho