Server side pagination vs Hybrid(Server + Client) Pagination
As a developer, I want to convert client side pagination into server side pagination. I have two options from which we need to select.
One is server side pagination, Server Side Pagination is when the server in which the data is hosted only returns a subset of the data requested by the Client. … Along with the subset of the query results, the server also sends us the total amount of results matching our query, and the location we are at within the query.
Second is Hybrid Pagination, in hybrid pagination, the user wants to switch between pages without any server side hit. In this approach, we are fetching data of 10 pages at once and then switch pages between 1 to 10. If a user wants to see a record of 11th page or later then a server side API is required to get the data of other pages and show accordingly.
If you are converting your client side pagination into Server side or Hybrid, then you must check the APIs required for it and it’s advantages.
- Server side pagination API — On change of every page we need to hit API to get the data from server of the required page. But in hybrid, we will fetch records of 10(k) pages. User can switch between pages from 1 to 10 without API hit(this is the only advantage of Hybrid Pagination), but as soon as we want to see record on 11th page, then again we need to hit API to get data from server. Which we are already implementing with Server side pagination only.
- Server side search API — Hybrid pagination doesn’t support search API. Both server side and hybrid required this API to get the searched data.
- Server side sort API — Again hybrid pagination doesn’t support sorting also. As for filtering/sorting we need filter all record and get all sorted items from server again, to see the sorting.
As a conclusion, Hybrid pagination has only 1 advantage over server side pagination. Which is, if user switch between pages till a particular number then they can switch without any API hit. Apart from switching between pages, hybrid pagination is not scalable and we can not fix a particular number on client, as this will be considered as a constant variable. Which is not a good practice to fix value on client side.
But in Server side pagination, we don’t fix any value at client side. We give user a flexibility to switch between pages from 1 to n. User can also change the page size and the records will be shown accordingly. It is more scalable and give better performance over hybrid pagination.
Also code complexity in hybrid pagination will increase, as we have to store a fix value at client side. This number is not used for any calculations, also if we try to show all pages at once then there will be almost same time taken to fetch records.
As a conclusion to above discussion, Hybrid Pagination will add complexity to code as well to functionality. So if application requires a large set of data to show, then me must use Server Side Pagination.