Thursday 17 April 2014

How to scroll a table in oracle ADF with large number of rows in database (>100K rows)?? Resolved!!

Hello ,

There are times in development when we have to show tables with large number of rows to user on the Page. ADF table contains very good property of Scroll which fetches the data from the database when the user scrolls in the table.
This works well when the number of rows in the table is less i.e we can say around 4-5000 without much problem. But the problem begins when we have Thousands or Lacks of rows in the table.

On the default settings when you scroll to the 10000th row then the table fetches all the data upto the 10000th row and then shows the results in the table. When the table starts fetching the 10000 rows in the memory then it takes time , here comes the problem. So if we can reduce this time then we can solve the problem.

Before solving the problem first we need to know why this problem comes into picture.
The problem is that when the user scrolls on the 10000th row, the framework start loading all the 10000 rows in the memory to show on the page, and this takes time.
For avoiding this problem we can customize the setting in ViewObject tuning section.
Go to the Tuning section of any ViewObject, you will see following options .


We have to focus on following properties.

# Retrieve rows from the database : It can be set to :

  1. All Rows (All the rows will be fetch at a time, when the number of rows are large then it takes so much time.)
  2. Only upto row number (Makes sure that only the rows upto the given number are fetched)
  3.  in batches of (It defines the number of rows fetched in one roundTrip to database. Its value depends on the use case but I this case we keep it to n+1, where n is the number of rows to be shown on the page. )
# Access Mode (This is the property to be concerned)
  1. Scrollable : when acess mode is scrollable it means as the user scrolls all the rows upto which user have scrolled will be loaded in the memory before it is shown on the page.
  2. Page Ranging : when the access mode is Page Ranging then when the user scrolls upto some row then only the rows that need to be displayed currently are loaded in to the memory. Let us take an example. Suppose the user scrolls to 10000th row then the RANGE containing row number 10000 will only get loaded into the memory.
So less time needed to load the rows hence table loads faster

# Range size 

It defines the range, We keep the range size to n+1 where n is the number of rows that the user needs to show on the page. 
Range size basically means the number of rows that will be loaded from the viewObject cache to the binding. This is kept to n+1 because if the we don't want more than one round trip to database as if the range size increases the fetch size then an another roundTrip to fetch values in issued.

Also keep the range of the table in sync with the range size of of the table, it helps. 

1 comment:

  1. http://adfjavacodes.blogspot.in/2014/04/adf-scrolling-in-table-with-large-data.html

    ReplyDelete