Hi all,to query something like this?
Novice MUMPer here. I am trying to query a large dataset using M and was wondering how to efficiently query a global.
For example, how does one filter for 10,000 of the most recent records (by Unix Time) which have a pattern of ^table(*,"A","C")? For a small list size, one could write some kind of $data/$order counting loop, but is that really the most efficient way
^table(1639615761233,"A","B")=1
^table(1639615761499,"A","C")=1
^table(1639615761761,"A","D")=0
^table(1639615762029,"A","E")=1
^table(1639615762298,"A","F")=1
^table(1639615762696,"A","G")=0
^table(1639615763508,"B","C")=0
^table(1639615763821,"B","D")=0
^table(1639615764099,"B","E")=0
^table(1639615764380,"B","F")=1
^table(1639615764640,"B","G")=1
^table(1639615768122,"D","C")=0
^table(1639615769781,"D","F")=1
^table(1639616032012,"A","B")=0
^table(1639616032294,"A","C")=0
^table(1639616032565,"A","D")=1
(...)
Hi all,to query something like this?
Novice MUMPer here. I am trying to query a large dataset using M and was wondering how to efficiently query a global.
For example, how does one filter for 10,000 of the most recent records (by Unix Time) which have a pattern of ^table(*,"A","C")? For a small list size, one could write some kind of $data/$order counting loop, but is that really the most efficient way
^table(1639615761233,"A","B")=1you can $order -1 and use the counter to read the last 10,000 records ...
^table(1639615761499,"A","C")=1
^table(1639615761761,"A","D")=0
^table(1639615762029,"A","E")=1
^table(1639615762298,"A","F")=1
^table(1639615762696,"A","G")=0
^table(1639615763508,"B","C")=0
^table(1639615763821,"B","D")=0
^table(1639615764099,"B","E")=0
^table(1639615764380,"B","F")=1
^table(1639615764640,"B","G")=1
^table(1639615768122,"D","C")=0
^table(1639615769781,"D","F")=1
^table(1639616032012,"A","B")=0
^table(1639616032294,"A","C")=0
^table(1639616032565,"A","D")=1
(...)
To me, the most straightforward approach seems to be something like:Ed wins! :-) I was putting together the same method, but he beat me to it.
Set max=10000,count=0,reference="^table" For Do Quit:reference="" Quit:count'<max
. Set reference=$Query(@reference,-1) Quit:reference=""
. Quit:reference'["""A"",""C"")"
. Set count=count+1,result(reference)=1
. Quit
Quit
(please note that this medium compresses double spaces to single ones, so there should be 2 spaces following the For, Do and Quit commands)
To me, the most straightforward approach seems to be something like:
Set max=10000,count=0,reference="^table" For Do Quit:reference="" Quit:count'<max
. Set reference=$Query(@reference,-1) Quit:reference=""
. Quit:reference'["""A"",""C"")"
. Set count=count+1,result(reference)=1
. Quit
Quit
(please note that this medium compresses double spaces to single ones, so there should be 2 spaces following the For, Do and Quit com
On Friday, December 17, 2021 at 11:44:35 AM UTC-5, ed de moel wrote:
To me, the most straightforward approach seems to be something like:
Set max=10000,count=0,reference="^table" For Do Quit:reference="" Quit:count'<max
. Set reference=$Query(@reference,-1) Quit:reference=""
. Quit:reference'["""A"",""C"")"
. Set count=count+1,result(reference)=1
. Quit
Quit
(please note that this medium compresses double spaces to single ones, so there should be 2 spaces following the For, Do and Quit commands)Ed wins! :-) I was putting together the same method, but he beat me to it.
OldMster schrieb am Freitag, 17. Dezember 2021 um 23:03:35 UTC+1:
On Friday, December 17, 2021 at 11:44:35 AM UTC-5, ed de moel wrote:
To me, the most straightforward approach seems to be something like:
Set max=10000,count=0,reference="^table" For Do Quit:reference="" Quit:count'<max
. Set reference=$Query(@reference,-1) Quit:reference=""
. Quit:reference'["""A"",""C"")"
. Set count=count+1,result(reference)=1
. Quit
Quit
I don't agree.(please note that this medium compresses double spaces to single ones, so there should be 2 spaces following the For, Do and Quit commands)Ed wins! :-) I was putting together the same method, but he beat me to it.
I'd code:
S count=0,time="" F S time=$O(^table(time),-1) Q:time=""!(count>9999) D
.I $D(^table(time,"A","C")) W time,^table(time,"A","C"),! S count=count+1
Q
Or do I overlook something?
OldMster schrieb am Freitag, 17. Dezember 2021 um 23:03:35 UTC+1:
On Friday, December 17, 2021 at 11:44:35 AM UTC-5, ed de moel wrote:
To me, the most straightforward approach seems to be something like:
Set max=10000,count=0,reference="^table" For Do Quit:reference="" Quit:count'<max
. Set reference=$Query(@reference,-1) Quit:reference=""
. Quit:reference'["""A"",""C"")"
. Set count=count+1,result(reference)=1
. Quit
Quit
I don't agree.(please note that this medium compresses double spaces to single ones, so there should be 2 spaces following the For, Do and Quit commands)Ed wins! :-) I was putting together the same method, but he beat me to it.
I'd code:
S count=0,time="" F S time=$O(^table(time),-1) Q:time=""!(count>9999) D
.I $D(^table(time,"A","C")) W time,^table(time,"A","C"),! S count=count+1
Q
Or do I overlook something?
To me, the most straightforward approach seems to be something like:
Set max=10000,count=0,reference="^table" For Do Quit:reference="" Quit:count'<max
. Set reference=$Query(@reference,-1) Quit:reference=""
. Quit:reference'["""A"",""C"")"
. Set count=count+1,result(reference)=1
. Quit
Quit
(please note that this medium compresses double spaces to single ones, so there should be 2 spaces following the For, Do and Quit commands)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 228:39:41 |
Calls: | 6,624 |
Calls today: | 6 |
Files: | 12,171 |
Messages: | 5,318,994 |