Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load a page of data at a time

I've got a data grid with pages with more than 10k rows so its very slow when it first loads. whats the best way of solving this problem. I've read that JDBC paging is the usual solution for such problem but some people are saying to use SQL ROWNUM is an easier solution so I wanted to ask first.

If you think paging is the best solution could you please give me a couple of pointers on how to go on about it(link to implimentation etc)

like image 766
code511788465541441 Avatar asked Dec 23 '10 14:12

code511788465541441


People also ask

What does it mean to load a page?

A page load begins when a user selects a hyperlink, submits a form, or types a URL in a browser. This is also referred to as the initial request or the navigation start. The user's action sends a request across the network to the web application server. The request reaches the application for processing.

How do you record time to load a website?

Chrome -> Right Click -> Inspect Element -> Network Tab. When you load a page there is a nice report for the timeline of the page showing the actual page load time, css, js etc. load times. There is a similar tool in Mozilla under Net tab.

What is page load time and why it is important?

Page load time indicates the time needed to download and view the whole content of a web page in the browser window. This parameter is also called “page speed” (speed of the page load).

What is page load performance?

Page load time refers to how long it takes for a page to show up on the screen. Timing starts when a customer initiates a page transition by clicking a link or typing a URL into your browser and ends when the page fully loads.


2 Answers

Paging is appropriate, and the tactic in the first answer to this question should work for Oracle.

like image 133
Don Roby Avatar answered Sep 19 '22 07:09

Don Roby


It's a very good question, and there is no single good answer for each case. I've used and seen various strategies, each of them has its pros and contras.

Loading at once - well, this one is good with small tables, and when data is filtered. When user navigates to other pages, no additional queries are sent to database. The minus - heavy cost at begin of interaction, and very heavy memory requirements. When the typicas is, the user will not scroll the whole data, it's the waste of resources. However, for small dictionaries, it's propably the best solution.

Paging using limit/offset (PostgreSQL), rownum (Oracle) or whatever the keyword is. The plus - high load time for first page. The minus - each next page is loaded slowlier, with heavier work on database site. The best strategy when user will typically see one or a few first pages. The worst, when the user will scroll through all data. It works quite good when the set is ordered by primary key, however it's terrible when the data set is filtered and ordered not by index. For each page it invokes filtering (propably with full table scan) and sorting full data set in memory!

Scrolling using database cursor. This is the most dangerous strategy. The database opens the cursor for query and when user requires next page, cursor is mooved. The optimal strategy for case, when user typically scrolls through all the data. The preferred strategy for reports. Hovewer, in user interactive mode it requires the database connection to be locked for the time of interaction. No one other can use it! And the number of connections to database is limited! It is also very hard to implement in web application, where you don't know if user closed the browser or is still analysing the data - you don't know when to release the connection.

like image 31
Danubian Sailor Avatar answered Sep 21 '22 07:09

Danubian Sailor