Search This Blog

Showing posts with label Add Pagination for Large Datasets. Show all posts
Showing posts with label Add Pagination for Large Datasets. Show all posts

Monday, June 30, 2025

How do I Add Pagination for Large Datasets

 Handling large datasets efficiently is crucial in Oracle APEX applications to ensure fast loading times and a smooth user experience. One effective way to manage this is by adding pagination to your reports and data displays. Pagination divides the dataset into manageable pages, allowing users to navigate through data without overwhelming the browser or the server with excessive information all at once. This technique not only improves performance but also enhances readability and usability when working with extensive records.

In Oracle APEX, adding pagination for large datasets is essential to improve application performance and user experience. Pagination breaks down large query results into smaller, more manageable pages, reducing load times and making navigation through data easier.

Classic Reports support automatic pagination, which helps display large amounts of data efficiently. This prevents performance issues when dealing with thousands of rows.

Pagination settings can be configured in the Report Attributes section:

  • Rows per Page: Defines how many records appear per page

  • Pagination Type: Options include "Link to Next Set of Rows", "Row Ranges", and "Scroll"

This makes Classic Reports useful for handling large tables without affecting performance.

To add pagination in Oracle APEX, follow these detailed steps:

  1. Create or Edit Your Report Region
    Typically, pagination is applied to report regions like Classic Reports, Interactive Reports, or Interactive Grids. Begin by creating a new report page or editing an existing one that displays your large dataset.

  2. Use Built-in Pagination Controls

    • Interactive Reports and Interactive Grids:
      Pagination is enabled by default. Users can navigate pages using the pagination bar at the bottom or top of the report, and you can customize the number of rows displayed per page.
      To adjust the pagination settings:

      • Go to the report region attributes.

      • Locate the “Pagination” section.

      • Set the “Rows per Page” value to a suitable number (e.g., 10, 25, 50, 100). This controls how many rows show on each page.

      • Optionally, allow the user to change rows per page by enabling the “Show Rows Per Page” control.

  3. For Classic Reports
    Classic Reports do not have built-in pagination like Interactive Reports, but you can implement pagination manually by:

    • Using the ROWNUM or ROW_NUMBER() analytic function in your SQL query to limit rows displayed based on page number and page size.

    • Creating page items or application items for “Current Page” and “Rows Per Page.”

    • Using these values in your SQL query’s WHERE clause to fetch only the relevant rows for the current page.

    • Adding buttons or links to navigate between pages, updating the “Current Page” value accordingly.

  4. Example SQL for Pagination in Classic Reports

WITH PaginatedData AS (
  SELECT
    your_columns,
    ROW_NUMBER() OVER (ORDER BY some_column) AS rn
  FROM your_table
)
SELECT *
FROM PaginatedData
WHERE rn BETWEEN :P1_PAGE * :P1_ROWS_PER_PAGE - :P1_ROWS_PER_PAGE + 1
  AND :P1_PAGE * :P1_ROWS_PER_PAGE

In this example, :P1_PAGE is the current page number, and :P1_ROWS_PER_PAGE is the number of rows per page.

  1. Enhance User Navigation
    To improve usability, add page navigation buttons or links (First, Previous, Next, Last) and ensure the current page number is visible. You can implement these as buttons or dynamic actions that change the current page value and refresh the report region.

  2. Performance Considerations
    Pagination not only improves user experience but also reduces database workload by fetching only a subset of data per request. Always use efficient queries with proper indexing on sorting columns to optimize pagination performance.

By leveraging built-in pagination features in Interactive Reports and Interactive Grids or implementing manual pagination for Classic Reports, you ensure your Oracle APEX applications handle large datasets efficiently and remain responsive for users.

Implementing pagination in Oracle APEX is straightforward and customizable, enabling you to control the number of rows per page and the navigation style. Properly configured pagination ensures that your application remains responsive and user-friendly, even as data grows in volume. By adopting pagination for large datasets, you improve both the efficiency and professionalism of your Oracle APEX applications, delivering a better experience for your end users.