I did this to verify my approach looping over a simulated table of 100 mio rows

  • SQL procedure TEST1 uses an external Class Method based on anna.INC
  • SQL procedure TEST2 uses an internal Class Method based on anna.INC

The difference is evident:

[SQL]SAMPLES>>select A.HUGE_fill(100000000)
18.     select A.HUGE_fill(100000000)
 
| Expression_1 |
| -- |
| ^A.HUGED=100000000 |
 
1 Rows(s) Affected
statement prepare time(s)/globals/cmds/disk: 0.0008s/5/828/0ms
          execute time(s)/globals/cmds/disk: 18.8332s/100,000,002/200,000,445/0ms
                                query class: %sqlcq.SAMPLES.cls3
---------------------------------------------------------------------------
[SQL]SAMPLES>>select list(A.HUGE_TEST1(ID)) from A.HUGE
19.     select list(A.HUGE_TEST1(ID)) from A.HUGE
 
| Aggregate_1 |
| -- |
|  |
 
1 Rows(s) Affected
statement prepare time(s)/globals/cmds/disk: 0.0005s/4/141/0ms
          execute time(s)/globals/cmds/disk: 101.5573s/100,000,001/700,000,424/0ms
                                query class: %sqlcq.SAMPLES.cls2
---------------------------------------------------------------------------
[SQL]SAMPLES>>select list(A.HUGE_TEST2(ID)) from A.HUGE
20.     select list(A.HUGE_TEST2(ID)) from A.HUGE
 
| Aggregate_1 |
| -- |
|  |
 
1 Rows(s) Affected
statement prepare time(s)/globals/cmds/disk: 0.0005s/4/141/0ms
          execute time(s)/globals/cmds/disk: 72.1640s/100,000,001/700,000,424/0ms
                                query class: %sqlcq.SAMPLES.cls1
---------------------------------------------------------------------------
[SQL]SAMPLES>>

Rough calculation: including the code in the class saves ~30% of execution time

my class code

Include anna
Class A.HUGE Extends (%Persistent, %Populate)
{
Property calc As %Integer [ Calculated, SqlComputeCode = { set {*}={%%ID}}, SqlComputed ];
ClassMethod fill(size) As %String [ SqlProc ]
{
	for i=1:1:size set ^A.HUGED(i)=""
	set ^A.HUGED=i
	quit $ZR_"="_@$ZR
}
ClassMethod test1(val) As %String [ SqlProc ]
{
	quit ##class(A.PERSON).Anna(val)
}
ClassMethod test2(val) As %String [ SqlProc ]
{
	quit $$anna(val)
}

The simplified anna,INC just returns NullString to concentrate on code switching

anna(name) 
 quit ""

Loading compiled obj code from cache to partition should not have any remarkable impact.
But you are right by principle ! It's some kind of overhead and not for free.

If you place the affected code into a .INC routine you may share that piece
rather easy over multiple instances.
Though mostly not used in that way any Include may also contain executable code.
For a :MAC routine it's  nothing impressive.
For Class code it's a bit tricky but works as well

example ANNA.INC

anna(name) ;
 write !,"Hello ",name,!
 quit ">>>"_name_"<<<"

example Anna.CLS
 

/// demo for Anna
Include ANNA
Class A.Anna {
ClassMethod demo(name As %String) As %String
{
	quit $$anna(name)
}
}

It works:

SAMPLES>write "===",##class(A.Anna).demo("robert")
===
Hello robert
>>>robert<<<
SAMPLES>

So multiple loading is reduced.

You have of course also the option to compose a Custom Command in %ZLANG***.MAC
I just have no experience of how this impacts partition loading.
 

#1) in %SYS find the sessions by this Stored Procedure:

#2 Next based on the SessionId I can open the Object
 

%SYS>set sess=##class(%CSP.Session).%OpenId("kTkyVXwgxw")
%SYS>set pid=sess.ProcessId
%SYS>if $l(pid) set tSC=$$DeleteSession^%SYS.cspServer(pid)

The last row was found in  
Class %CSP.UI.Portal.CSPSessions
ClassMethod EndSession

Attention. Not every CSP Session has also a pid ! 

not just Sample.Person but also Sample.Address,
or whatever serial class you refer to require %JSON Adaptor.
then

set person=##class(Sample.Person).%OpenId(3)
>set sc=person.%JSONExportToString(.Jperson)
set zjson={}.%FromJSON(Jperson)
ZWRITE
Jperson="{"LIMIT":103,"Name":"O'Rielly,Xavier E.","SSN":"331-77-5308","DOB":"1957-05-26","Home":{"Street":"8757 Elm Place","City":"Miami","State":"FL","Zip":"92027"},"Office":{"Street":"413 First Drive","City":"Miami","State":"NH","Zip":"83830"},"Age":67,"RowVer":0}"
person=<OBJECT REFERENCE>[2@Sample.Person]
sc=1
zjson=<OBJECT REFERENCE>[13@%Library.DynamicObject]

and there is your dynamic object

From Ensemble.inc:
 

#define TRACE(%arg)             $$$catTRACE("user",%arg)
#define sysTRACE(%arg)          $$$catTRACE("system",%arg)
#define catTRACE(%cat,%arg)     Do:$$$DoTrace ##class(Ens.Util.Trace).WriteTrace(%cat,$$$CurrentClass,$$$CurrentMethod,%arg)
#;
#define DoTrace                 $S($D($$$EnsJobLocal("DoTrace")):$$$EnsJobLocal("DoTrace"),1:##class(Ens.Util.Trace).DoTrace())
#;
#define EnsJobLocal         %Ensemble
#;
. . . . 
Class Ens.Util.Trace [ Abstract, ClassType = "", ProcedureBlock, System = 4 ]
{
ClassMethod DoTrace()
{
	Set tJobConfigName=$$$JobConfigName
	Quit $G($$$ConfigTrace(tJobConfigName),0)||(""'=$G($$$JobTraceDevice))||$$$IsTerminalDevice($IO)
}

I just identified a possible source of the hidden Python installation:
https://docs.intersystems.com/iris20243/csp/docbook/DocBook.UI.Page.cls?KEY=GEPYTHON_prereqs#GEPYTHON_prereqs_version

Microsoft Windows does not come with a default version of Python, and
as of InterSystems IRIS 2024.2, the InterSystems IRIS installer for Windows
no longer installs Python for you.

I did an upgrade from my previous  IRIS 2024.1 

Your file format doesn't fit, but you are close.
UDL Header is missing, also leading blanks in the lines as you have no labels.
And you have to switch to namespace %SYS and back to make it work.

ROUTINE DisplayDB[Type=INT]
 new $namespace
 zn "%SYS"
 set db=##class(Config.Databases).DatabasesByServer("",.dbList)
 for i=1:1:$LENGTH(dbList,",") {
   set dbName= $PIECE(dbList,",",i)
   write dbName,!
 }
 quit

Try this from %Library.Routine: 
https://docs.intersystems.com/iris20243/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25SYS&CLASSNAME=%25Library.Routine#Delete
with flag=2

classmethod Delete(rtnname As %String, flag As %String = 0, supressbackup As %Boolean = 0, nsp As %String = $namespace) as %Status

Delete the routine rtnname. If the rtnname is not fully qualified we will resolve this into a fully qualified name first and then proceed with the rest of the delete. For example if you specify 'test' and there is a 'test.mac' it will resolve to this, if there was only a 'test.obj' it will resolve the name to this. The parameter flag specifies how much to delete. The options are:

  • 0 - Delete entire routine, for a MAC routine this will delete MAC, INT, OBJ. For an INT routine it will delete INT and OBJ, for a INC routine it will only delete the INC, for a BAS routine it will delete the BAS and the OBJ code.
  • 1 - Delete just the named routine, for example for a MAC routine it will only delete the MAC and it will leave the INT and OBJ if present.
  • 2 - Delete all the source code but leave any OBJ code.

something like this ?

| COL    | VAL |
| ------ | --- |
| codRep |        401,       428,       428,       464,       472 |
|  Abril |     100000,    180000,    160000,         0,         0 |
| Agosto |     100000,    350000,    200000,     90000,         0 |

then this is the SQL statement
 

SELECT 'codRep' "COL", list($JUSTIFY(codRepresentante,10)) "VAL"
   FROM Ped.MetasRepresen where ano=2024
Union All
SELECT ' Abril', list($JUSTIFY(vendasAbril,10)) 
   FROM Ped.MetasRepresen where ano=2024
Union All
SELECT 'Agosto', list($JUSTIFY(vendasAgosto,10))
   FROM Ped.MetasRepresen where ano=2024

like this:

/// using $ZZFIX() custom function
Class rcc.GetFixZZ Extends %Library.String
{
Parameter LENGTH As %String = 10;
Parameter ALIGN As %String = "LEFT";
Parameter PADCHAR As %String = " ";
Method Get() As %String [ CodeMode = generator, ServerOnly = 1 ]
{
	set code=+%parameter("LENGTH")_","""_$E(%parameter("PADCHAR")_" ",1)_""""
	set code=code_","_("RIGHT"=$zcvt(%parameter("ALIGN"),"U"))_")"
	$$$GENERATE(" quit $ZZFIX(%val,"_code )
	QUIT $$$OK
}
ClassMethod StorageToLogical(%val As %String) As %String [ CodeMode = generator, ServerOnly = 1 ]
{
	set code=+%parameter("LENGTH")_","""_$E(%parameter("PADCHAR")_" ",1)_""""
	set code=code_","_("RIGHT"=$zcvt(%parameter("ALIGN"),"U"))_")"
	$$$GENERATE(" quit $ZZFIX(%val,"_code )
	QUIT $$$OK
} }