Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is server and client side pagination?

Tags:

php

pagination

Is server side pagination where the pagination script calculates the number of entries in a database then make the links? All I know is server side is faster and better if there is alot of data and client side is using javascript?

What makes a pagination script server or client side?

Also, right now I am planning to use this pagination which is like digg-style. Can someone tell me if that is server-side pagination? (sorry if my terminology is off)

like image 631
ggfan Avatar asked May 11 '10 02:05

ggfan


People also ask

What is client-side pagination and server-side?

Client-side pagination is for a small amount of data and is primarily for presentation purposes. Server side pagination handles large amount data, and provides stability and scalability.

What is server-side pagination?

Operations and Engineering Dashboards supports server side pagination grid. Server side pagination is considered useful for large-sets of data as the amount of data that is transferred to the client is much smaller than the data handled by the client.

What is client-side paging?

Client Side Pagination means that when a query is made, the server returns to the client all the data in one big chunk. Client Side Pagination is more like going to a restaurant and ordering one of everything on the menu. The time it takes the kitchen to produce all that food is going to be significantly longer.

What is client-side and server-side with example?

Client-side means that the processing takes place on the user's computer. It requires browsers to run the scripts on the client machine without involving any processing on the server. Server-side means that the processing takes place on a web server.


2 Answers

Server side pagination:

The server takes a number of parameters from the user (current page #, ordering, etc) and performs whatever search required to get just the relevant records. These are sent to the client, along with links to more pages, etc.

Each time the user clicks a link, you get a page refresh showing the new data.

Useful when:

  • there's many results or the payload for each result is quite large
  • looking up/processing the results is very time consuming
  • users rarely go past the first page

Not so great because:

  • Each click is a round trip to the server, which might take some time
  • Maintaining state is a PITA

Client side pagination:

The server sends all available records to the client, and using Javascript, these results are split into pages and rendered client-side. Changing pages or item ordering is as good as instant, and requires no server interaction. This makes it much easier to cache the results on the server side.

Useful when:

  • There's not many results (only a handful of pages)
  • Users will be using many pages (therefore sending the extra data isn't a waste)
  • Splitting up a form: because each page of inputs is merely being hidden and not removed, the entire form can be sent in one form submit.

Not so great because:

  • The initial page load is much larger
  • Might cause problems for users without JS on (though graceful degradation is quite possible)
  • You may need to duplicate your display logic into Javascript.

A Blended approach

Write your application to fully use server-side pagination. Once that is working, use javascript to intercept all links which change the page or the ordering, and send those requests via AJAX. Adapt your server-side script to return just the HTML necessary for any given page, and none of the page chrome around it when it is responding to an AJAX request.

Benefits:

  • Minimal payload for each page-turn = faster response times.
  • Completely scalable.
  • Degrades perfectly.
like image 109
nickf Avatar answered Oct 10 '22 20:10

nickf


Client side is when you pull all the data down and then the client segments the data into pages.

Server-side is usually done by the client providing a key that is passed to the server and then the server only selects out that "page" of data. For example if you were displaying people by last name, the first page might be created by telling the server that you want people with the last name of 'A' and that you want 10 rows returned.

The server would do something like:

SELECT ssn, fname, lname 
FROM people 
WHERE lname like 'a%' and rownum <= 10 ORDER BY lname, ssn;

If the last/10th record has a last name of 'abbot' with an SSN of 555555555, then the next page could be retrieved by the client passing those values back to the server which would then do something such as:

SELECT ssn, fname, lname 
FROM people 
WHERE lname >= 'abbot' and ssn > 555555555 and rownum <= 10 ORDER BY lname, ssn;

Server-side is considered better for large-sets of data as the amount of data transferred to the client is far smaller than if all the data is pulled down and "paged" by the client. It also lowers the memory required for the client side as well as taking advantage of the strong capabilities of databases to sort data or use existing sorted indexes to speed selection.

like image 31
RC. Avatar answered Oct 10 '22 20:10

RC.