Article
· Mar 7 1m read

Performing index rebuild in multiple processes while using an application

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

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)

3. Register the index name to be rebuilt in the INDEXBUILDERFILTER parameter of the class definition.

Index HomeStateIdx On Home.State;
Parameter INDEXBUILDERFILTER = "HomeStateIdx";

4. Compile the class.
5. Use the %ConstructIndicesParallel() method to rebuild indexes in parallel.

set st=##class(Sample.Person).%ConstructIndicesParallel()

6. After rebuilding the index, expose the added index to the optimizer.

>write $system.SQL.SetMapSelectability("Sample.Person","HomeStateIdx",1)
1

Please refer to the following document for details.

How to rebuild the index while the application is running【IRIS】

How to rebuild the index while the application is running

Discussion (0)1
Log in or sign up to continue