Hi Jerry,
Without knowing more about the specific query plan and IRIS setup it would be hard to know what's going on - I would highly recommend reaching out to the WRC about this if you are able. I will note that TUNE TABLE has had significant functionality improvements since IRIS version 2021.2 (see https://community.intersystems.com/post/20212-sql-feature-spotlight-smar...) , it's possible you are missing a bug fix; again WRC would be the best point of contact. Best of luck!
Following up on this from a recent customer conversation: the current best practices that we have settled on has been disabling exportselectivity as in Ben De Boe's post (https://community.intersystems.com/post/cicd-iris-sql), alongside ensuring AdaptiveMode is turned on (https://docs.intersystems.com/iris20243/csp/docbook/Doc.View.cls?KEY=RAC...). For now this will ensure that initially collected stats aren't overwritten, and once table statistics are collected automatically this should be completely "hands off".
One way to do this would be to make use of the 'iris merge' command with a CPF file: https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
The CPF file in question can run $SYSTEM.Obj.Load as an Action, for example:
[Actions]
Execute:Namespace="USER",ClassName=%SYSTEM.OBJ,MethodName="Load",Arg1="/home/irisowner/dev/cls/TestClass.xml",Arg2="ck"
So the steps here would be:
1. Define a CPF file that loads the classes you need
2. Create a unix script that runs 'iris merge <instance name> <CPF file location>'