since every installation of Caché has it's gateway I'm not clear what you did by
" configured as CSP gateway. "
with no manual change the gateway always talks to your local server  ser-app-w

From CSPgatewayMgmt on ser-app-w  you should check access to ser-app-db

so you may use $$$comClassDefined(class)  for compile classes

or go for ^oddCOM(....)

And if you also want to be sure that also the Method %New exists you my use

write $$$comMemberDefined(ClassName,"m","%New")

[just reading through]

I'm fully with you.
Using hidden %System.whatever   Classes is as bad practice as using undocumented $zu(anynumber,  ,  , )

set exist=##class(%Dictionary.CompiledClass).%ExistsId(ClassName)

will tell you the status

If there is an index defined on PBD_PBO_ParRef  is it correctly generated?
If not sure, do rebuild index from MgmtPortal. 

What about chopping your query like this or similar


"Select TOP 10000 ID,Text from eprinstance.isegment where ID > ?"

passing lastID as query Parameter

Now you loop on it until you collected all records.

The basic idea is to limit your result set by TOP as your partition allows.

wink it's definitely independent of Cache versions.