Db2

 View Only

 SYSTOOLS.POLICY

Mark Gillis's profile image
Mark Gillis IBM Champion posted Thu January 22, 2026 06:39 AM

Hi 

has anyone got any SQL that helps query the contents of the SYSTOOLS.POLICY table? I'm experimenting with the AI Optimiser and have created an AUTO_AIOPT policy (after a bit of a struggle and a lot of help from Brandon Frendo at the IBM labs) but I'm curious to know if I can see what other profiles there might be in there? Or is there a simpler and cleaner way of finding this out?

Incidentally, if you do a search through the Knowledge Centre, you get 0 hits for SYSTOOLS.POLICY and if you Google it you get 

Regards

Mark Gillis

Jan Nelken's profile image
Jan Nelken IBM Champion

Mark,

I believe that table SYSTOOLS.POLICY contains defined policies; stored procedure procedure AUTOMAINT_SET_POLICY defines those policies:


On my sample database I can query SYSTOOLS.POLICY table and find out definition of the TableAIOptDecision (it's an XML document stored as BLOB:

Mark Gillis's profile image
Mark Gillis IBM Champion

Hi Jan; yes that's the mechanism for putting the XML into the POLICY table (that or the AUTOMAINT_SET_POLICYFILE Proc which is what I used). I was hoping for something that was a bit more elegant for examining the contents of BLOB column but this will do the trick:

SELECT NAME , XMLPARSE(DOCUMENT CAST(POLICY AS VARCHAR(2000)) STRIP WHITESPACE) AS POLICY FROM SYSTOOLS.POLICY 

I'm just trying to find out a little more about what is going on under the covers as

a) the contents of the column contain a bit more than the data I submitted as a policy, and

b) they don't seem to be working; i.e. my policy should limit the operation of the AI Optimiser to just the tables in a specific schema, but it is creating models for other schemas too.

I might try my contact in the labs and see if they can give me some pointers

Regards

Mark

Mark Gillis's profile image
Mark Gillis IBM Champion

At the risk of just answering my own question, I did find out that my policy "not working" was due to me having mis-coded it. I subsequently established (through trial and error) that your policy Filter Conditions are not syntactically checked and you can put in any old garbage and have it successfully loaded as a policy. I'm just checking that with the chaps at the labs.

Oh, and your best bet for extracting a policy to confirm what you have is

export to TableAIOptPolicy.xml of del modified by nochardel SELECT XMLPARSE(DOCUMENT CAST(POLICY AS VARCHAR(2000)) STRIP WHITESPACE) AS POLICY 
FROM SYSTOOLS.POLICY 
WHERE Name='TableAIOptPolicy'

and then look at TableAIOptPolicy.xml.001.xml.

If you let MS Edge load that as a default, it will format it nicely as an XML doc so you can easily eyeball it

Regards

Mark