Written by

Senior Startups and Community Programs Manager at InterSystems Corporation
Question Evgeny Shvarov · Nov 30, 2017

Index Globals: Take Away or Rebuild?

Hi, Community!

Consider you move data from one server to another or make a deployment with persistent data. What do you do with index globals?

Is it always better to rebuild them or there are some cases when it worth to take them too?

Comments

Tom Fitzgibbon · Nov 30, 2017

I've rarely rebuilt indexes while moving Cache DBs. It's a complex added step that is probably not worth doing unless you have very large DB or limited copy throughput.

Tom Fitzgibbon gototomAtG...l

0
Gerd Nachtsheim  Nov 30, 2017 to Robert Cemper

Agree with Robert (how couldn't I? ;) )

The crucial questions is how long does it take to copy the index vs. rebuilding it? And, if your index has not been rebuilt for a long time, will a reorganized global be beneficial to your performance? It usually is.

Also note that the recent versions of %BuildIndices() exploit multiple cores whenever possible and will run much faster than the older, serialized approach.

As Eduard mentioned, functional indices, or indices on collection with handcrafted BuildValueArray() for that matter, may be a different beast and may run for a long time. 

0
Robert Cemper  Dec 1, 2017 to Evgeny Shvarov

It's a rare case in combination with %Persistent,
but it makes sense also to exclude any class with Property Abstract=1 in your Query

0
Eduard Lebedyuk  Dec 1, 2017 to Evgeny Shvarov

Would skip classes with  several levels of inheritance from %Persistent. Use SubclassOf query instead.

0
Eduard Lebedyuk · Nov 30, 2017

Complex functional indices which take a long time to build my be worth moving, otherwise - no.

0
Robert Cemper · Nov 30, 2017

Rebuild takes time -  ONCE
and gives you the unique chance to fill the created index in contiguous global content blocks.
That pays back at ever access by less global pointer blocks whatever storage technology you use.

0
Evgeny Shvarov · Dec 1, 2017

Thanks for the answers!

The combined answer is - build it again if you don't care about the time during deployment.

For Caché persistent classes I like this snippet from [@Kyle Baxter] which rebuilds all persistent classes' indexes in a Namespace:

s sql="select Name from %Dictionary.CompiledClass where system=0 and NOT(Name %Startswith '%') AND SUPER [ 'Persistent'"

s rs=##class(%SQL.Statement).%ExecDirect(,sql)

while rs.%Next() { s sc= $classmethod(rs.%GetData(1),"%BuildIndices") w "Built "_rs.%GetData(1)_" with return code = "_sc,! }

0