Don’t use Spring Data Page with Vaadin

Be careful when using Spring Data:
Spring Data performs two queries: one to count and one to fetch when Page is returned. Instead, you can use Slice.

Page doesn’t make sense with Vaadins DataProvider because you either don’t provide a count or the count is separate from the fetch callback

Example project: GitHub - simasch/spring-data-page

2 Likes

I remember a ticket about this :) : Don't use findAll(Pageable pageable) · Issue #103 · vaadin/starters · GitHub

It’s a bit sad that it’s inefficient

1 Like

I’ve been cringing at my logs looking at the queries that are generated when I use the standard tooling rather than rolling my own queries for everything like I did in my old (Vaadin 7, then 17, then 21, then 24) app I used to manage.

It really is quite inefficient.

Always turn on SQL logging during development and analyze the queries

I seems to me that the objection that you can’t use a Specification with Slice is still valid, although it should be solved in spring-data-jpa 4 (so usable in vaadin 25?)

1 Like