Speeding up $listget
Hi,
I'm trying to find the faster way to get the data from a class, and I find it very slow compared to traditional globals. So, I hope some of you can bring some light to me :-)
I have thousands of registers in a class, and to access it quickly I'm going with $o at the index. From there, I get the values using $listget(). Something like that:
s FromDateH = (+$h-1)
for {
set id=$order(^TestI("StartDateIDX",FromDateH,id))
quit:id=""
set dat=$lg(^TestD(id)) //dat=$lb("a","b","c","d","e")
}
I find it quite slow, so I've tried the same code but changing the conents of ^TEST from a List to a String:
s FromDateH = (+$h-1)
for {
set id=$order(^TESTINDEX("StartDateIDX",FromDateH,id))
quit:id=""
set dat=$g(^TEST2(id)) //dat = "a#b#c#d#e"
}
I find that getting the data from a String (like "a#b#c#d#e") is 4 to 5 times faster than getting it from a List (like $lb("a","b","c","d","e")). When you are managing a few records it may not make a differenc but in my case its having a huge impact.
Does anyone know how can I speed up the $listget() so the performance is similar as the old fashioned MUMPS way to get the string separated values?
Cheers! :-)