In many use cases, there is a generic requirement to show the list of data to user. User should be able to see the list of data, to perform search and sorting operations on this data. User should also be able to navigate to any data record anytime. This requirement demands to fetch the large amount of data from database and list it on UI for the user. Then this data can be filtered using various search criteria and can be sorted also depending upon user input. Approach to fetch the data can be different depending upon architecture and implementation of application, like data can be fetched directly from database in case of embedded applications, or 2 tier architecture or through some services in 3 tier architecture. The process flow used to be like:
- Take inputs from user what kind of data she wants to see
- Interact with database directly or through service (depending upon architecture) to get this data
- Display this data to user
- Filter or sort the data depending upon user action on UI
For example, open google.com. Search for any word. You will get search results in list form, and various page number given at the bottom of the page to navigate to different pages.
Now if there are thousands of data records in database for given inputs, all of this data can not be shown to user in one go. Showing this on same screen will be having problems like:
- It will not be a good experience for user, as she will need to scroll up and down a lot and information will be unreadable practically.
- It will not be good for performance of application, as application may get out of memory or may face slow response due to large amount of data in memory, or data transfer from database.
To solve first problem mentioned above, we need to divide the data in small parts to show the user one part at a time. For example, we can divide data in parts having 50 records each. Then each of the parts can be shown to user one by one. Once user see first part, she can request for next or previous part and hence corresponding 50 records can again be shown on screen to user. These parts are called pages, and this process is called pagination - which divides the large data in pages (having limited records) and show these to user.