0

I am facing the performance issue on jsp. Application was design in year 2002 on struts 1.x using jsp and javascripts. There is one case where we have to show approx 1 million records to user on selecting specific category. Its like there are two select box on jsp name as A and B. A is having list of (category approx 1000) . On selecting category we have to show sub-category in select box 2 (approx 1 million records). (java script function is there to hit sever and get the records on same jsp) Currently we are facing lot of issues regarding performance.

Please suggest the best way of displaying such records to user in existing way(using 2 select box on jsp), or any other best approach.

Shubham Jain
  • 33
  • 1
  • 8
  • 1
    I would have to say "don't" is the best way. I can't imagine any user wants to deal with 1 million of something on their screen, and I'd be concerned about resources on a small system like mobile. – markspace Oct 24 '17 at 16:37
  • 1
    https://stackoverflow.com/questions/14035180/jquery-load-more-data-on-scroll – mplungjan Oct 24 '17 at 16:38
  • Its a web project recommended to run only on desktops. yes its a requirement and user wants to see the one million records on screen. Its like monitoring of order details product is used by cargo and shipment organizations. – Shubham Jain Oct 24 '17 at 16:48
  • 1
    But ... but ... that's insane. Computers are for filtering information, not users. – Teemu Oct 24 '17 at 16:52
  • Teemu its like we have to implement this. – Shubham Jain Oct 24 '17 at 16:58
  • 1
    Huh ... I made a fiddle, added a select element with a million options. When running in FF, it created the element within a half of a minute, but opening the select practically crashed the browser. It took 6GB of RAM at the time I shooted FF down ... – Teemu Oct 24 '17 at 17:09

1 Answers1

2

Wading through 1000000 records isn't fun for anyone. I would introduce paging and some filters/search so that users can limit the results.

If you absolutely must display a list of a million rows, you could build a component that renders the list, but only renders the rows that are visible. So, you'd give your scroll area an inner height of (rowHeight * numberOfRows), and when someone scrolls to a part, you use ajax to load just that data from the server and render the items that would go in that area and absolutely position them in the right spot. The technique is called object pooling: https://en.wikipedia.org/wiki/Object_pool_pattern. This allows you to not have to load all million items from the server, and you only have to render a few of them at a time.

frodo2975
  • 10,340
  • 3
  • 34
  • 41
  • Thanks sir. Pagination is the last option for us. is there any other best approach for this by using jquery and ajex or something more good then that – Shubham Jain Oct 24 '17 at 16:57
  • Updated my answer, you could build a component that only renders the rows that would be visible – frodo2975 Oct 25 '17 at 18:54