[docs] Add instructions to recreate a partition index#31362
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a new section to the YSQL documentation titled "Recreate a partition index", providing a step-by-step guide for recreating indexes on partitioned tables online using a detach-and-reattach strategy. The feedback suggests changing the language tag of the example code block from "plpgsql" to "sql" to ensure more accurate syntax highlighting, as the block contains standard SQL statements rather than procedural code.
| To recreate indexes, you should avoid directly creating an index on the partitioned table (parent table) because that cannot use `CONCURRENTLY`. | ||
| Follow these steps to recreate a partition index online: | ||
|
|
||
| ```plpgsql |
✅ Deploy Preview for infallible-bardeen-164bc9 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
aishwarya24
left a comment
There was a problem hiding this comment.
LGTM with minor comments.
| - Parallel writes are expected while creating the index, because concurrent builds for indexes on partitioned tables aren't supported. In this case, it's better to use concurrent builds to create indexes on each partition individually. | ||
| - [Row-level geo-partitioning](../../../../../explore/multi-region-deployments/row-level-geo-partitioning/) is being used. In this case, create the index separately on each partition to customize the tablespace in which each index is created. | ||
| - `CREATE INDEX CONCURRENTLY` is not supported for partitioned tables (see [CONCURRENTLY](#concurrently)). As a workaround, you can use the [ONLY](#only) keyword to create indexes on child partitions separately, as described in that section. | ||
|
|
There was a problem hiding this comment.
Lets add a link to the "Recreate a partition index" section something like:
- To rebuild unique indexes on partitions online without running
CREATE INDEX CONCURRENTLYon the parent, see Recreate a partition index.
| ``` | ||
|
|
||
| Repeat steps 1–9 for `child1`, `child2`, and any other partitions as needed. | ||
| Step 4 to lock the parent is optional if there will be no reads or writes against the parent table while the partition is detached. |
There was a problem hiding this comment.
| Step 4 to lock the parent is optional if there will be no reads or writes against the parent table while the partition is detached. |
|
|
||
| {{< note title="Note" >}} | ||
|
|
||
| Step 4 requires object locking support (available since 2025.2): set YB-TServer flags `enable_object_locking_for_table_locks=true` and `ysql_yb_ddl_transaction_block_enabled=true`. |
There was a problem hiding this comment.
| Step 4 requires object locking support (available since 2025.2): set YB-TServer flags `enable_object_locking_for_table_locks=true` and `ysql_yb_ddl_transaction_block_enabled=true`. | |
| {{< note title="Note" >}} | |
| Step 4 to lock the parent is optional if there are no reads or writes against the parent table while the partition is detached, and it requires enabling object locking (supported from YugabyteDB {{<release "2025.2">}} or later). | |
| To enable the feature, set the YB-TServer flags `enable_object_locking_for_table_locks=true` and `ysql_yb_ddl_transaction_block_enabled=true`. Refer to Refer to [Enable table-level locks](../../../../../explore/transactions/explicit-locking/#enable-table-level-locks) for more details. | |
| {{< /note >}} |
No description provided.