官术网_书友最值得收藏!

  • Mastering PostgreSQL 12
  • Hans Jürgen Sch?nig
  • 158字
  • 2021-08-20 10:00:19

Rebuilding indexes concurrently

Once in a while, it can be necessary (in rare circumstances) to recreate an index. For quite some time, PostgreSQL has provided CREATE INDEX CONCURRENTLY, which allows end users to create an index while a table is under a heavy write load. A normal CREATE INDEX statement blocks the table while the index is created and, therefore, it is hardly possible to create large indexes in a 24 x 7 OLTP database. 

However, in some cases, it might be necessary to recreate all indexes in a database or a specific schema. PostgreSQL 12 allows you to run REINDEX CONCURRENTLY on an entire database, schema, or table:

test=# \h REINDEX
Command: REINDEX
Description: rebuild indexes
Syntax:
REINDEX [ ( VERBOSE ) ] { INDEX | TABLE | SCHEMA | DATABASE | SYSTEM } [ CONCURRENTLY ] name

URL: https://www.postgresql.org/docs/12/sql-reindex.html

REINDEX CONCURRENTLY will dramatically reduce the pain caused by REINDEX and achieve results with minimal locking.

主站蜘蛛池模板: 崇义县| 阿图什市| 当阳市| 邢台市| 西藏| 环江| 固阳县| 进贤县| 镇江市| 池州市| 定兴县| 永济市| 永寿县| 岳阳县| 本溪| 谷城县| 静宁县| 桑植县| 兴城市| 修水县| 灌阳县| 温泉县| 兰考县| 佛教| 滨州市| 于都县| 金乡县| 新乐市| 江阴市| 宁夏| 苍梧县| 南漳县| 彝良县| 星座| 普洱| 东乌珠穆沁旗| 宁阳县| 缙云县| 闽侯县| 鹤壁市| 长兴县|