1) $replace(pRequest.GetValueAt("MSH::MessageType.MessageType),"^","") instead of pRequest.GetValueAt("MSH::MessageType.MessageStructure",,tSC)

2) $e($zdt($h,8),1,8) instead of $tr($zdt($h,3),"-: ","")

I didn't notice that you have your "personal" schema category : ORUBeakerLAB

I don't have a great knowledge about InterSystems plans.

But, generally, you just should first delete your plan and then recreate the index.

35 seconds were quite important!

How much records or mostly probably different jointures on tables?

Don't rely too much on this !

w $System.SQL.CEILING(1.000000000000000001)

2

w $System.SQL.CEILING(1.0000000000000000001)

1