Something to try is to search through the instHeaders instead of the instances. The instHeader defines the virtual memory master for the instances. It is much quicker becasue there are fewer instHeaders than instances.
schIh = setof( ih csv~>instHeaders ih~>cellName == "option" )
schInsts = foreach( mapcan schIh schIh~>instances )
; Check the last line because I don't have Virtuoso access from home
; It should return a flattened list of the instances of the cell option
layIh = setof( ih clv~>instHeaders ih~>cellName == "option" )
layInsts = foreach( mapcan layIh layIh~>instances )
I think mapcan is the right mappng function to use but read about them as they are very useful.
It will greatly speed up your program as you are only sorting a few instHeaders.
You can also make a DPL or a table which will map the schematic values using the schematic instance name. I would use a table:
schParamValue = makeTable('values "" )
;; Add the pipe to the beginning of the name
schParamValue[strcat( "|" inst~>name) ] = dbSearchPropByName( inst "connectivity")~>value
In the layout processing part you can then get the layout instance name and get the value from the table directly:
dbReplaceProp( inst "connectivity" 'string schParamValue[layoutInst~>name]
Look up the table data structure for more info.