What grid.getLazyDataView().getItems() will do ?

List<> myList = grid.getLazyDataView().getItems().toList();

It will do lazy loading all items of list ? what it does internally ?

It calls fetch with an empty query object. Just test it :wink:

fetch all data from DB one time ? anyway, i need to test your source code :rofl:

oh, it fetch all items in DB.
fetch(verifiedDataCommunicator.buildQuery(0, Integer.MAX_VALUE))

From javadocs:

Get the full data available to the component. Data is filtered and sorted the same way as in the component.

in term of performance. using pagination as below is better ?:
Pageable pageable = PageRequest.of(0, 50); Page<Company> page = null; do { // we iterate each pages until the last page page = companyDAO.findAll(pageable); List<Company> listCompany = page.getContent(); // process listCompany // move to the next page pageable = page.nextPageable(); } while (page.hasNext() && !page.isEmpty());

No it’s slower.

i want avoid fetch all rows from table at once which we may load huge data.
Say my user table got 100k rows (of user email).
I want to fetch all users to send them email.

then using grid.getLazyDataView().getItems().toList(); OR pagination is better for performance ?

Pagination by 50 items means a lot of queries.

you mean grid.getLazyDataView().getItems() will do one time fetch all rows from DB to memory. So we no need to do more query to DB which is faster than pagination ?

@quick-witted-echidna

Anyway, to fetch and process huge recordset I would not use Flow Data api, but perhaps raw JDBC or check for some Spring specific helper (e.g. Spring Data JPA :: Spring Data JPA even if I don’t remember if the Stream scrolls over the JDBC ResultSet)

pagination is spring data

so back to original question:
pagination vs stream query vs grid.getLazyDataView().getItems().
Which one is best performance for query large data like read all records (eg. 100k rows) in a table ?

Yes, but with pagination you may perform many queries, as @faithful-emu said. I was thinking at Jpa Repository method returning a stream or something in JdbcTemplate

The flow data API is great to get the same filters/order ( if you can filter the grid).

yes, if your data in table is big. do one time fetch query may overflow your memory

so i thinking of pagination which not load many data to memory at a time

In one shot you will need more memory. You might need to paginate it ( but with a good amount of data). It depends on your memory available and the size of each row/object)

yes. now my data can be 10 KB/row. so one shoot may overflow my memory. @quick-witted-echidna

If you only need the email, build a dedicated query that just selects a single column and apply some JPA hints and voila it’s one single query with instant results.