Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading first page of data quickly over HTTP

Tags:

.net

ajax

paging

Pretty normal scenario:

  • I have a report with a large number of rows (>2000) to be rendered as an HTML table.
  • I am paging the results on the client (browser) side.
  • I want to render the first page as quickly as possible, the rest will continue to download as JSON (about 1MB total)

I want to use a single request to the server because the database query is expensive (and I don't want to cache anything on the web server)... so I am thinking of using Comet or flushing just the first page's data, then flushing more script tags for the rest of the data.

Is this feasible? Are there any tutorials/examples of this?

Thanks.

like image 569
Jeff Meatball Yang Avatar asked Feb 27 '23 10:02

Jeff Meatball Yang


2 Answers

Quite feasible; however I'd do it by making two calls.

On a lower-level protocol it'd be easy to flush but I recall something funny about flushing json.

like image 92
Joshua Avatar answered Mar 07 '23 00:03

Joshua


Change server side interface to accept from and to params, so that you have control over how much gets fetched. Make/change a spoc in SQL to do efficient paging on SQL side (paging part will look like Row_number() OVER(order by MyColumn)). That will actually make first query much faster end-to end (SQL will be sending less that 5% of data - say 100 rows). Then in the second query you can get all the rest or you can split it in 2 or more parts (SQL server is happier sending non-giant blocks as well - efficient paging is relatively new feature - like 5yr old).

like image 40
ZXX Avatar answered Mar 07 '23 00:03

ZXX