InterSystems FAQ rubric
You can use the %IndexBuilder
class to perform index rebuilding using multiple processes.
Here is an example for the purpose of defining the standard index HomeStateIdx for the Home_State (state information of contact address) column of Sample.Person.
The steps are as follows:
1. Hide the index name to be added/rebuilt from the query optimizer.
>write $system.SQL.SetMapSelectability("Sample.Person","HomeStateIdx",0)
1
ObjectScriptObjectScript
2. Add %IndexBuilder
to the rightmost superclass of the class definition that defines the new index.
///The class definition statement is as follows (add it at the far right)
Class Sample.Person Extends (%Persistent, %Populate, %XML.Adaptor, %Library.IndexBuilder)
ObjectScriptObjectScript
3. Register the index name to be rebuilt in the INDEXBUILDERFILTER
parameter of the class definition.
Index HomeStateIdx On Home.State;
Parameter INDEXBUILDERFILTER = "HomeStateIdx";
ObjectScriptObjectScript
4. Compile the class.
5. Use the %ConstructIndicesParallel()
method to rebuild indexes in parallel.
set st=##class(Sample.Person).%ConstructIndicesParallel()
ObjectScriptObjectScript
6. After rebuilding the index, expose the added index to the optimizer.
>write $system.SQL.SetMapSelectability("Sample.Person","HomeStateIdx",1)
1
ObjectScriptObjectScript
Please refer to the following document for details.
How to rebuild the index while the application is running【IRIS】