Reputation: 23
For an in-memory table, I can use sublist or take syntax to retrieve first x, last x elements.
How to do this efficiently for an on-disk table which may be very large? The constraint is that I don't want to cache all the data from table to memory to run the query.
Upvotes: 2
Views: 5646
Reputation: 19
I suppose you can use the i column which is the row number (per partition!) on a historical.
So the first row would be select from trade where date=first date, i = 0
The last row would I guess be select from trade where date=last date, i=max i
This assumes normal partitioned by date stuff. If you have just a non-partitioned tables, probably select from trade where i=0
would be fine
Upvotes: 1
Reputation: 2605
.Q.ind - it takes a table and (long!) indices into the table - and returns the appropriate rows http://code.kx.com/q/ref/dotq/#qind-partitioned-index
Upvotes: 1