Hi Jean,

at first glance I'd expect the query plan for #18. and #19. should be quite similar
:SQL offers 3 levels to see the query plan

  • show                  
    • Show the execution plan for the current statement.
  • show pl[an] [v[erbose]]                          
    • Shows the current statement execution plan.                          
    • If the verbose qualifier is used, show all the module                          
    • details for the current statement's execution plan;                          
    • Otherwise, display only the top-level module details                        
    •  by default.
  • show planalt [v[erbose]]                          
    • Shows the current statement alternate execution plans.                          
    • If the verbose qualifier is used, show all the module                          
    • details for the current statement's execution plan and                          
    • all alternate plans; Otherwise, display only the                          
    • top-level module details by default..

This might offer a chance to identify the difference.

There's still an - unlikely - chance that #19  runs on some broken cached query,
that never was updated. so clear cached queries might be a possible solution. Not an explanation 

Best regards, Robert

Hello community;

  • My name is Robert C. Cemper, graduate engineer from Vienna Technical University
  • I'm Austrian, born and still living in Vienna for 77 years. I'm married once and have 3 aged children.
  • Over the years I worked with several big companies in the emerging IT market, like SIEMENS, Olivetti, Digital Equipment, Compaq, ... finally InterSystems. My special story with InterSystems is available in this article 45 Years with Intersystems
  • Actually I'm  "retired but not tired" and follow Developer Community with unbroken interest. Especially because I had a similar proposal 10 years before it finally materialized. My feelings for it are quite similar to a grandfather  
  • My special interests are the core functionalities of the Global Storage, ObjectScript and SQL
  • Working close to the internals is my core competence, but also all network stuff. Actually im focusing on  Docker in the OpenExchange environment. 
  • My top hobby are computers for about 60 years and my whole career was based on it. I started with a console panel with toggle switches for the address and some others for the content. One of my teachers built the first transistor based computer in Europe.  Other hobbies like music, theater, skiing, hiking, biking, travel to other countries changed importance over time. At my retirement I returned to University to catch up with progress in Physics, especially Quantum Physics, Cosmology, Paleology, ... I also added Latin to my set of 4 spoken + 2 written languages.
  • I stopped LinkedIn as I was spammed by unacceptable job offers.
  • Due to health and social limitations I will not attend  READY 2025      

#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 ! 

OK

To Stream needs 1 line 2 statements
 

ClassMethod personsidGET(messageRequest As dc.Sample.v3rest.requests.personsidGET) As %Stream.Object
{
 set stream=##class(%Stream.TmpCharacter).%New(),sc=##class(dc.Sample.Person).%OpenId(messageRequest.pathid).%JSONExportToStream(.stream)
 return stream
 }

To String is shorter (just 1 statement) as you don't need to initialize %String)

ClassMethod personsidGET(messageRequest As dc.Sample.v3rest.requests.personsidGET) As %String
 do ##class(dc.Sample.Person).%OpenId(messageRequest.pathid).%JSONExportToString(.string)
 return string
{

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