Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is there an equivalent to T-SQL's "top n" in Gigaspaces SQLQuery?

Our product deals with large numbers of numeric-valued, dated observations. They are conceptually ordered by date, but they can come into the system out-of-order. Each observation has a "trend" value, which is a measure of how different its numerical value is from the numerical value of the previous observation. Obviously, if a new observation comes in, we need to calculate a trend for this new observation AND for the one that immediately follows it in time.

Consider a new observation Ox. We need an efficient way of calculating these trends. One way to do this would be to use two "top n" queries. One would get the observation Ow just before Ox (so I can calculate the trend for Ox itself). The other would get the observation Oy just after Ox (so I can REcalculate its trend).

Of course, either or both of Ow and Oy may not exist.

We could do this by reading ALL observations, sorting them, and finding Ow and Oy by walking the list -- but there could be hundreds of thousands of observations, I'd much prefer that Gigaspaces found Ow and Oy for me.