-1

I have an APP that saves in a session bean a large list (100.000+ records)

It takes 2 to 3 seconds to load the grid or any changes, and I want it faster.

Is there any way to make the data "lazy" while rendering the page but still having all the data in the session bean?

In the primefaces doc they have an example of a "lazyclass" I cant do that, the managedbean cannot extend such class

Alexev
  • 157
  • 2
  • 19
  • 5
    why your mbean cant call the lazy class? – strash Apr 18 '17 at 19:36
  • Because the example in https://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml takes 4 clases for a single view. Is very complex. – Alexev Apr 18 '17 at 19:59
  • 5
    _"Is there any way to make the data "lazy" while rendering the page but still having all the data in the session bean"_ Sure, that is **exactely** what they do in the PrimeFaces showcase for lazy loading... (which is sort of a 'bad' example in that regard which some people cannot look beyond). But are you 1000% sure you want 100.000 records in your session bean? And the showcase is an **example** which you can and **should** tailor to your needs... 3 classes are almost always needed if you want to have good separation of concerns... Only the 'sorter' is not needed if you sort in the database – Kukeltje Apr 18 '17 at 20:01
  • 5
    Just wondering, who could possibly look at +100k records? – dic19 Apr 18 '17 at 20:13

1 Answers1

0

How are you loading the grid?

You can try to make a buffer for it. If you load the list fast, but initializing the view with such a big list is slow, you can just initialize it, with smaller list- the first part of the big data, and later add more data.

You can see how to split your list here: Java: how can I split an ArrayList in multiple small ArrayLists? Some companies nowadays work with all their data stored in the RAM for fastest operations. So in memory design is not for underestimation. 100 000 is not so much every machine can handle it.

Java 8 Stream API can handle the list filtering and querying very effective.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
strash
  • 1,291
  • 2
  • 15
  • 29
  • @Kukeltje its my answer to that question. The question is broad so the answer is broad but I think its in a good direction. – strash Apr 18 '17 at 20:06
  • and its possible – strash Apr 18 '17 at 20:06
  • 1
    Sure, but this is **exactly** what the PF showcase does... And loading 100.000 records in a session and then paging over some of them (max 100? or 1000?) is a bad design... suppose you have 100 users, than you have 10.000.000 records in memory of which you only show 10.000 at the same time... – Kukeltje Apr 18 '17 at 20:12
  • I have more than 100 users, because of that I have a application scoped bean with the 100.000+ records, the problem is that the list in memory needs to show something for some users and other for other users – Alexev Apr 18 '17 at 20:16
  • that is in memory database almost. Some companies nowadays work with all their data stored in the RAM for fastest operations. So in memory design is not for underestimation. 100 000 is not so much – strash Apr 18 '17 at 20:23
  • I will take a look at the splitting option, the thing is, the users needs to serach and work with all the datasets, so If they have to make a query to the database everytime they need to look for a series of data the waiting time is huge. That is the reason I choose to save a copy of the current list in a application scoped bean. It works, everyone is happy with the 2secs waiting but when the system gets bigger the 2 secs will be 3 and 4 and 5 and I want to avoid that – Alexev Apr 18 '17 at 20:24
  • Other approach is to implement PAGING in the view. – strash Apr 18 '17 at 20:25
  • and your user queries will be just with the number of the page they want, and you will be showing your sublist from 0-1000, then from 1001-2000 etc.. – strash Apr 18 '17 at 20:26
  • I am using paging, 40 records per view, but when the page loads the first time it talkes 3 secs, But I am using primefaces datatable pagination, it seems slow anyway – Alexev Apr 18 '17 at 20:42
  • so thats your solution- initialize your view with the first 40 records, then after the initialization, update the view with all the records and maybe it will work nice – strash Apr 18 '17 at 20:49
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/142016/discussion-between-gen-strash-and-alexev). – strash Apr 18 '17 at 20:50
  • 3
    Application scoped **is not** session scoped as stated in your question. And all that is mentioned here is 1000% what the PrimeFaces showcase does... 1000% – Kukeltje Apr 18 '17 at 22:17
  • The 100.000k list is in an application scoped bean, then a portion of it is in other lists (plural) in users sesion scoped because of their different roles – Alexev Apr 19 '17 at 14:24