title: How to improve jquery datatable performance to load large data efficiently with 1,00,000 records
body: <p>I am using jquery datatable with minimal configuration to showcase data on my website. I have 1,00,000 records to show in datatable.</p>
  
  <p>Currently the datatable is taking too much time to initialize the records. so systems going to hangout mode. </p>
  
  <p>I am using JSON return data from java side.</p>
  
  <p>jquery code here:</p>
  
  <pre><code>$("button#searchbutton").click(function() {                          
                            var fromDate = $("#fD").val();
                            var toDate = $("#tD").val();
                            url = "/Search?fromDate="+fromDate+"&amp;toDate="+toDate;                         
                           $('#table').DataTable({
                                "ajax" : url,
                                "bDestroy":true,
                                  "columns":[
                                      {"data": "txnid" },
                                      {"data": "date"},
                                      {"data": "Amount"}                                        
                                     ],
                                     "order": [[ 1, "desc" ]],
                                     "language": {
                                         "lengthMenu": "| View _MENU_ records per page",
                                         "zeroRecords": "Nothing found - sorry",
                                         "infoEmpty": "No records available",
                                         "infoFiltered": "(filtered from _MAX_ total records)"
                                     },
                                     "pagingType": "full_numbers",
                                    "lengthChange": false
                            });
                      });
  </code></pre>
  
  <p>Server Side Code here:</p>
  
  <pre><code>SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  @RequestMapping(value = "/Search", produces = "application/json")
  public @ResponseBody JSONObject getPendingList(@RequestParam(required = false) String fromDate,
          @RequestParam(required = false) String toDate,Model model) throws ParseException 
      {           
      List&lt;Map&lt;String, Object&gt;&gt; list = new ArrayList&lt;Map&lt;String, Object&gt;&gt;();
      Date fromDate1 = null;
      Date toDate1 = null;
      if (StringUtils.isEmpty(fromDate)) {
          fromDate1 = null;
      } else {
          fromDate1 = sf.parse(fromDate);
      }
      if (StringUtils.isEmpty(toDate)) {
          toDate1 = null;
      } else {
          toDate1 = sf.parse(toDate);
      }
          List&lt;AccountDetails&gt; list2 = service.getList(fromDate1, toDate1);   
          JSONObject ajson = null;
          if (list2 != null &amp;&amp; list2.size() != 0) {
              for (AccountDetails deatils : list2) {
                  Map&lt;String, Object&gt; map = new LinkedHashMap&lt;String, Object&gt;();
                  map.put("txnid", deatils.getTxnid());
                  map.put("amount", deatils.getAmount());
                  if(deatils.getTxnDate() != null){
                  map.put("date", sf.format(deatils.getTxnDate()));
                  }else{
                      map.put("date", "");
                  }
                  list.add(map);
              }
              ajson = new JSONObject();
              ajson.put("data", list);
          }else {
              ajson = new JSONObject();
              ajson.put("data", null);
          }
      }
  </code></pre>
  
  <p>Service Interface Here:</p>
  
  <pre><code>public List&lt;AccountDetails&gt; getList(fromDate1, toDate1);
  </code></pre>
  
  <p>Implementation Here:</p>
  
  <pre><code>@Override
      public List&lt;AccountDetails&gt; getList(Date fromDate, Date toDate) {
      Session session = entityManager.unwrap(Session.class);
      Criteria criteria = session.createCriteria(AccountDetails.class);
      System.out.println(fromDate+"********"+toDate);
          if (fromDate != null) {
              criteria.add(Restrictions.ge("txnDate", fromDate));
          }
          if (toDate != null) {
              criteria.add(Restrictions.le("txnDate", toDate));
          }
          return criteria.list();
      }
  </code></pre>
  
  <p>What are your suggestions for improving the load time?</p>