Performance: Pagination and sorting with Pageable
MEDIUM IMPACT
This concept affects how much data is loaded and rendered at once, impacting page load speed and responsiveness when displaying lists.
Pageable pageable = PageRequest.of(page, size, Sort.by("name").ascending());
Page<Item> items = itemRepository.findAll(pageable);List<Item> items = itemRepository.findAll(); // loads all items without pagination or sorting| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Load all data at once | High (many nodes) | Multiple reflows due to large DOM | High paint cost | [X] Bad |
| Use Pageable for pagination and sorting | Low (limited nodes) | Single reflow per page load | Low paint cost | [OK] Good |