the automation script is using the CLASSUSEWITH relationship (from the MBO) to identify which records to process.
The query to retrieve the records will only be processed once so the explain plan will be used once.
.
objList="";
useWithSet=mbo.getMboSet("CLASSUSEWITH")
if (not useWithSet.isEmpty()) :
s=useWithSet.getSize()
Looking at the script I can't see a reason why it should be particularly slow although it is repeatedly extending a string.
Consider using timing code to check which parts of the script are actually slow.
measure the time in lots of places and you will quickly see where the slow operations are
--
9.20 OPERATION: TIMING PART OF THE OPERATIONS OF A SCRIPT
The time module can be used to calculate the start/end time for sections.
import time
startTime = time.clock()
# do something
endTime = time.clock()
runDurationSecs = endTime - startTime
this is taken from Vetasi's Automation script course
--
It may be better to put the string value in a list and then build a string from the list.
I would expect that to be a much quicker process because it won't involve repeated modifications to the string object.
L = []
L.append(string)
I have created a modified version of this from here:
https://thispointer.com/python-how-to-convert-a-list-to-string/
this shows how to build a string from a list.
def convert_list_to_string(org_list, seperator=' '):
""" Convert list to string, by joining all item in list with given separator.
Returns the concatenated string """
return seperator.join(org_list)
# Join all the strings in list
full_str = convert_list_to_string(list_of_words, ',')
re the comment about isEmpty causing leaks - see this posting which explains the behaviour.
Maximo------------------------------
Mark Robbins
Support Lead/Technical Design Authority / IBM Champion 2017 & 2018 & 2019 & 2020 & 2021
Vetasi Limited
https://www.linkedin.com/pulse/maximo-support-advice-from-non-ibm-engineer-article-mark-robbins/------------------------------
Original Message:
Sent: Fri November 12, 2021 06:40 AM
From: Pankaj Bhide
Subject: Do automation scripts utilize database indexes?
Hello,
In you sql query you are filtering the rows with classstructureid=68070, while in the automation script that you pasted, you are looping through all the rows from the MBO classusewith (I don't find any filtering here).
Also, I don't think in your case, there is any need for the "getSize" method (which can trigger count(*) from table). Instead you can simply do something following:
if (not useWithSet.isEmpty()):
useWith= UseWithSet.moveFirst()
while (useWith):
........ your logic
.........
useWith= useWithSet.moveNext()
useWithSet=None
I recently heard from the forum that "useWithSet.isEmpty()" causes memory leaks which I did not understand. They alternatively suggested using notExists method.
------------------------------
Pankaj Bhide
Associate/Analyst
Berkeley National Laboratory
Berkeley CA
(510) 486-4681
------------------------------