From the docs: "Indicates not to recurse creating indexes on partitions, if the table is partitioned. The default is to recurse.".
Am I understand correctly that index will not be created on existing partitons? What kind of index will be created then (on what)?
2
Answers
The objective is to build a partitioned index with as little locking as possible.
Normally, you’d use
CREATE INDEX CONCURRENTLY
to create an index on each partition, thenCREATE INDEX
on the partitioned table. If the index definitions match, the previously created indexes will become partitions of the partitioned index. See this related question.The potential problem with that is that all partitions will be locked at the same time. Instead, you can do it one partition at a time:
create the index
ONLY
on the partitioned table (the index will be invalid)use
ALTER INDEX ... ATTACH PARTITION
to attach the indexes on the partitions as partitions of the indexonce all partitions are attached, the partitioned index will become valid
small demo example:
now is INVALID:
still INVALID.
then
now ISVALID.