title: Primefaces live scrolling taking long time with large datasets
body: <p>Hi I have a primefaces datatable with about 52000 records to be fetched.Since it is a large dataset,i tried using live scrolling feature of primefaces with scroll rows equal to 20.THe number of columns is 53.The table also has filtering and sorting feature on its each column.Still i am not satisfied with the performance of the table.It takes about 15 secs for the page to load,worst thing is that it takes about 65 secs for the next set of 20 records to be loaded on reaching the end of scrolling.</p>
  
  <p>Just for testing i reduced the total number of records to 25000 and the preformance improves with scroll time of 29 secs.<strong>I am really not able to understand why it is taking this much time when i am displaying only 20 records at a time.The total number of records should not have affected the performance.</strong></p>
  
  <p>Can  someone please suggest how to improve the performance.I cannot implement pagination for this since my customer don't want it.Thanks in advance</p>
  
  <p>My JSF code snippet</p>
  
  <pre><code>&lt;p:dataTable id="arcRecList" var="data"
              value="#{archivedRecordBean.archiveItems}"
              tableStyle="table-layout:auto; width:80%;" styleClass="datatable"
              scrollable="true" scrollWidth="84%" scrollHeight="69%"
              columnClasses="columnwidth" liveScroll="true" scrollRows="20"
              filteredValue="#{archivedRecordBean.filteredArchiveItems}"&gt;
  
  
              &lt;p:column style="width:250px" headerText="Insured"
                  filterBy="#{data.insuredName}" sortBy="#{data.insuredName}"&gt;
                  &lt;h:outputText value="#{data.insuredName}" /&gt;
              &lt;/p:column&gt;
  
              &lt;p:column style="width:250px" headerText="City"
                  filterBy="#{data.custAddress_City}"
                  sortBy="#{data.custAddress_City}"&gt;
                  &lt;h:outputText value="#{data.custAddress_City}" /&gt;
              &lt;/p:column&gt;
                  .
                  .
                  .53 columns
                  .
          &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>My Managed bean</p>
  
  <p>@ManagedBean</p>
  
  <p>@RequestScoped</p>
  
  <p>public class ArchivedRecordBean implements Serializable {</p>
  
  <pre><code>private List&lt;WorkSpaceItem&gt; archiveItems=null;
  private List&lt;WorkSpaceItem&gt;filteredArchiveItems;
  private WorkSpaceItem objWorkSpaceItem=null;
  JdbcConnection jdbcConnection=null;
  Connection connection=null;
  Statement selectStmt=null;
  ResultSet rs=null;
  public ArchivedRecordBean()
  
  {   
      getArchiveFields();
  
  }
  public List&lt;WorkSpaceItem&gt; getArchiveItems() {
      return archiveItems;
  }
  public void setArchiveItems(List&lt;WorkSpaceItem&gt; archiveItems) {
      this.archiveItems = archiveItems;
  }
  public WorkSpaceItem getObjWorkSpaceItem() {
      return objWorkSpaceItem;
  }
  public void setObjWorkSpaceItem(WorkSpaceItem objWorkSpaceItem) {
      this.objWorkSpaceItem = objWorkSpaceItem;
  }
  
  public List&lt;WorkSpaceItem&gt; getFilteredArchiveItems() {
      return filteredArchiveItems;
  }
  public void setFilteredArchiveItems(List&lt;WorkSpaceItem&gt; filteredArchiveItems) {
      this.filteredArchiveItems = filteredArchiveItems;
  }
  public void getArchiveFields()
  {
      try
      {
          jdbcConnection=new JdbcConnection();
          connection=jdbcConnection.getJdbcConnection();
          selectStmt=connection.createStatement();
          String query="select * from LPINFO where LPINFO.ClearDate &lt; (select TOP 1 Tbl_CurrentYear.CurrentYear from dbo.Tbl_CurrentYear)"
                  +"AND (LPINFO.ClearDate is not null)";
          rs=selectStmt.executeQuery(query);
          archiveItems=new ArrayList&lt;WorkSpaceItem&gt;();
          while(rs.next())
          {
  
              objWorkSpaceItem=new WorkSpaceItem();
              objWorkSpaceItem.setInsuredName(rs.getString("InsuredName"));
              objWorkSpaceItem.setCustAddress_City(rs.getString("CustAddress_City"));
              objWorkSpaceItem.setCustAddress_State(rs.getString("CustAddress_State"));
              .
              .
              .//Setting the values for remaining columns
              .
              .
              archiveItems.add(objWorkSpaceItem);
  
          }
  
      }
      catch(Exception e)
      {
          e.printStackTrace();
      }
      finally
      {
          try {
  
              connection.close();
          } catch (SQLException e) {
  
              e.printStackTrace();
          }
  
      }
  
  }
  </code></pre>
  
  <p>}</p>