Paging thru a long resultset w/o re-evaluating a query in the URL

My query takes a long time to run and it gives a long resultset that spans multiple pages. After clicking the pageDown link the URL becomes

http://localhost:7016/?[32

Can I write the query in such a way that it takes advantage of the row number in the URL to fetch just enough rows for display? The built-in hdb browser already does that. If I keep the resultset as an in-memory table it will take up memory, which is limited by kdb 32 bit. Thx.

I’m not exactly sure what you mean. Do you mean you want to see the entire result without paging?

As I mentioned in the other thread, you can increase buffer lilmit by executing system “C 2000 2000” in q. However, the web/console limit seems to be 2000 rows. Not sure is a way to change that limit

http://code.kx.com/wiki/Reference/CmdlineC

I want the paging to work on a resultset produced by an ad-hoc query in the URL. I need to page thru more than 2k rows.

An answer is probably in .z.ph
http://code.kx.com/wiki/Reference/dotzdotph

In the following query, computing a partial resultset takes a shorter time than computing the full resultset.

(a:{count til x} each til 1000*50)

This shows 0 to 32

http://localhost:7000/?{([]a:{count%20til%20x}%20each%20til%201000\*50)}[]

Clicking the pageDown link gives 32 to 64

http://localhost:7000/?[32

Clicking the pageDown link again gives 64 to 96

http://localhost:7000/?[64

All 50k rows are re-calculated (notice the pause) every time I click the pageDown link. Can I write the query to take the row number in the pageDown link as a parameter and compute only the rows needed for display? Thx.

hi yan,

maybe define t:

  q)t:(a:{count til x} each til 1000*50)   /  http://localhost:7000/?t

your expression is being evaluated each time.  ?t is easier to evaluate.

ta, jack 

I don’t even have the time to compute the full resultset in the first place. Memory consumption is another problem. The user is NOT LIKELY to cleanup after use.

> I don’t even have the time to compute the full resultset in the first place.

ah… you’re going to have to work out if you can find an expression to compute partial result sets. 

partial results for til 60 are  f:{(x*10)+til 10}

  f 0

  f 1

  f 2

   … 

if you can do that, it’s a matter of modifying the http handler so that users can navigate as they wish.
 
>
> Memory consumption is another problem. The user is NOT LIKELY to cleanup after use.

Will a simple query builder (html + frameset + jquery) be easier?

If you just need to page through results, html with .z.ph would be easier.

If you want a fancy HTML5 experience look at Websocket or JSON (both on wiki)

ta, jack