Thursday, April 11, 2013

VO Fetch Configuration


View Object Performance primarily depends on how it is fetching the data from the data base.
'Row Fetch limit' in adf-config limits the number of records to be retrieved from the data base.
Row Fetch limit is an application level setting and it applied to all the view objects in the application.
One can override this value for a particular VO by setting MaxFetchSize at the view object level.

Following are the two test cases with a row limit set to 500 while querying a table with 1000 records

Test Case1:
------------

Total Rows in table: 1000
Row Fetch Limit: 500 rows
Max Fetch Size = -1

<ViewObject
  xmlns="http://xmlns.oracle.com/bc4j"
  Name="VOConfigTestVO"
  Version="11.1.2.62.94"
  SelectList="VOConfigTestEO.NUM"
  FromList="FUSION.VO_TEST VOConfigTestEO"
  BindingStyle="OracleName"
  CustomQuery="false"
  PageIterMode="Full"
  UseGlueCode="false"
  FetchMode="FETCH_AS_NEEDED"
  FetchSize="1000">
 


In this testcase, while retrieving the records, the max fetch size is set to -1 (Default Value). But on the page, while retrieving, it is observed that there is an error while scrolling for records after 500.



Test Case2:
------------
Total Rows in table: 1000
Row Fetch Limit: 500 rows
Max Fetch Size = 900

<ViewObject
  xmlns="http://xmlns.oracle.com/bc4j"
  Name="VOConfigTestVO"
  Version="11.1.2.62.94"
  SelectList="VOConfigTestEO.NUM"
  FromList="FUSION.VO_TEST VOConfigTestEO"
  BindingStyle="OracleName"
  CustomQuery="false"
  PageIterMode="Full"
  UseGlueCode="false"
  FetchMode="FETCH_AS_NEEDED"
  FetchSize="1000"
  MaxFetchSize="900"> 


In this test case, we have overridden the row limit to 900 using MaFetchSize, after which we were able to retrieve 900 records from the database.

FetchSize:

In both these testcases, FetchSize attribute is set to 1000, which means we would retrieve 1000 records from DB in one trip. By Default the value is set to 1, which was taking long time while scrolling the records.

RowCount Threshold:
While displaying the table, to accurately size the scroll bar for the table, application would actually execute a select count query on the View object to estimate the number of records. This select count query can be a costly query with an increase in user wait time ans also it has a negative impact on memory. One can control this behavior using a property called RowCountThreshold on iterator binding.

In the Test Case1, RowCountThreshold is set to 0 and following query is seen in the log:

<ViewObjectImpl> <buildQuery> [401] SELECT VOConfigTestEO.NUM FROM FUSION.VO_TEST VOConfigTestEO WHERE ROWNUM <= 501
<ViewObjectImpl> <getCappedQueryHitCount> [402] ViewObject: [model.view.VOConfigTestVO]VOConfigTestAM.VOConfigTestVO1 Capped Row Count Query Statement:
<ViewObjectImpl> <getCappedQueryHitCount> [403] "SELECT count(1) FROM (SELECT VOConfigTestEO.NUM FROM FUSION.VO_TEST VOConfigTestEO WHERE ROWNUM <= 501) "
<ViewObjectImpl> <getCappedQueryHitCount> [404] Bind params for ViewObject.getCappedQueryHitCount: VOConfigTestVO1
<ADFLogger> <addContextData> Estimated row count
<ViewObjectImpl> <getCappedQueryHitCount> [405] ViewObject: [model.view.VOConfigTestVO]VOConfigTestAM.VOConfigTestVO1 Capped Row Count (501): 501


When we set this RowCountThreshold to -1, Capped Row Count Query wont be fired, to size the scrollbar. So with this option, the scroll bar size wont be fixed on the load of the page and it  would become smaller as more rows are retrieved.

Also i found  this nice article on the VO tuning part written by Vinod Krishnan. 

Monday, April 8, 2013

Usage of Content Delivery on ADF Popup

ADF Popup is a container and the data is delivered to the client based on the property "contentDelivery". The possible options for this property are lazy, immediate and uncached.

lazy: Use the option lazy, when you dont want the content to be loaded till the popup gets opened once. In this option, the content would be cached.
lazyUncached: As the name signifies, it too doesnt load the content till the pop up is opened up, like in the previous case.But, the data wouldnt be cached. One should use this property when the popup has data which can be modified. This option makes sure that the data is loaded everytime a popup is opened up thus avoids stale data.
immediate: Loads contents of the popup on the page load. This ensures the data is displayed fast and ideally this option should be set when the usecase mandates the user to click the popup.

ADF Popup supports two serverside events: a) PopupFetchEvent b)PopupCanceledEvent

Popup Fetch Event s invoked during content delivery which means, this event gets raised only when the content delivery property is set to lazy/lazy uncached

Wednesday, April 3, 2013

Generic Array Creation

I was trying to create a new Generic Stack and noticed an issue.This might be a trivial one, but surprisingly, i never came across this issue. My Bad.

public class Stack<T> {
    private T[] array;
    int header;
    public Stack() {
       array = new T[25]; -- Compilation issue
       setHeader(-1);
    }

In the above mentioned step, during Compile time, Java doesn't know anything about T, so through erasure, it would be reduced to Object class. In which case, it would treat the statement as
T[] array = new Object[25] -- which is an error.

This link gives more information on why Generic Array Creation is a compilation issue