window join is a generalization of asof join. asof join takes a snapshot of current state. window join aggregates all values of specified columns within an interval.
/ i have taq 2003.09.10(5.6M trades and 35M quotes) on my laptop d:`:/taq/2003.09.10 x:select sym,time,price from d`trade q:select sym,time,bid,ask from d`quote f:`sym`time / 264,000 trades outside (bid;ask) \t a:select from aj[f;x;q]where not price within(bid;ask) / 4 seconds to process 5.6M trades against 35M quotes w:-3000 1000 / look at quotes from 3 seconds before to 1 second after \t b:select from wj[w;f;x;(q;(max;`ask);(min;`bid))]where not price within(bid;ask) / 28 seconds to do all the windows. max ask and min bid within each window \t c:select from wj[w;f;a;(q;(max;`ask);(min;`bid))]where not price within(bid;ask) / same result in 1.4seconds by using initial aj snapshot
now 37,000 violations instead of 264,000
For a complete list of functions, see the kdb+ Function Reference.