Improving Performance

I?m wondering if there’s a more efficient way of achievingsomething …I have a table defining intervals of time, defined by a start and endtime (ie. time pairs at minute resolution):tp: ( start: 06:00 06:12 14:17 14:00; end: 06:15 06:28 14:19 14:45)Now, if I have a minute ?m?, and I want to find all the rows (timeintervals) which cover this minute, then I can do this:q)m: 06:13 / example minuteq)select from tp where start<=m, end>=mstart end-----------06:00 06:1506:12 06:28That?s all fine. But suppose now I have a list of minutes, instead ofjust one, and I want to do this operation on all three:q)m: 06:13 11:50 14:14 / three minutes nowI guessI can just iterate, like this:q){[m] select from tp where start<=t,end>=t } each m+startend!(06:00 06:12;06:15 06:28)+startend!(06:00 06:12;06:15 06:28)+startend!(06:00 06:12;06:15 06:28)Is there some faster, sneakier way I?m missing (given that ?tp? isbig, and so is ?m?)?Cheers,Mike

On Dec 3, 11:30?pm, Mike Thompson <mike.thompsona…> wrote:> I?m wondering if there’s a more efficient way of achieving> something …>> I have a table defining intervals of time, defined by a start and end> time ?(ie. time pairs at minute resolution):> tp: ( start: 06:00 06:12 14:17 14:00; end: 06:15 06:28 14:19 14:45)>> Now, if I have a minute ?m?, and I want to find all the rows (time> intervals) which cover this minute, then I can do this:>> q)m: ?06:13 ? ? ?/ example minute> q)select from tp where start<=m, end>=m> start end> -----------> 06:00 06:15> 06:12 06:28>> That?s all fine. ?But suppose now I have a list of minutes, instead of> just one, and I want to do this operation on all three:>> q)m: 06:13 11:50 14:14 ? ? ? ?/ three minutes now>> I guessI can just iterate, like this:>> q){[m] select from tp where start<=t,end>=t } each m> +startend!(06:00 06:12;06:15 06:28)> +startend!(06:00 06:12;06:15 06:28)> +startend!(06:00 06:12;06:15 06:28)>> Is there some faster, sneakier way I?m missing (given that ?tp? is> big, and so is ?m?)?>I have a followup question:Instead of having just a single ?m?, imagine I have a table of othertime intervals, and for each I want to find the set of rows in tpwhich overlap.q)tp2: ( start: 06:00 13:00 14:00; end: 06:59 13:59 14:15)/ for each interval in tp2, find the intervals in tp1 which overlapq){ select from tp where start<=x[end],end&gt;=x[start] } each tp2+startend!(06:00 06:12;06:15 06:28)+startend!(minute$();minute$())+startend!(,14:00;,14:45)Is there a better way?</mike.thompsona…>

>
> q){[m] select from tp where start<=t,end>=t } each m

Sorry, meant:

{select from tp where start<=x,end>=x } each m