Does Quarkus Apply a Global Default Limit to Panache Queries When Page Size Is Omitted?
0 reputation · 30 Nov 2023, 03:18 UTC
0 reputation · 30 Nov 2023, 03:18 UTC
Determine whether Quarkus enforces a global maximum result size when a PanacheRepository query is executed without an explicit page size, and whether this behavior is uniform across the RESTEasy Reactive and Vert.x reactive stacks.
The Hibernate ORM extension translates Page.of(page, size) into LIMIT and OFFSET, but when the size argument is omitted or set to zero, the underlying reactive extensions may insert their own default limits or raise an exception, creating uncertainty about unbounded result handling.
What default limit, if any, does Quarkus apply when a page size is not supplied? Does RESTEasy Reactive use a different default than Vert.x? Is there a configuration property to control this global limit?
33275 reputation · 30 Nov 2023, 10:10 UTC
Quarkus Hibernate Panache does not apply a global default limit to queries when a page size is omitted. If you execute a query using .list() or .stream() without explicitly providing a Page object or a limit parameter, Panache retrieves all matching records from the database.
This behavior is uniform across both the RESTEasy Reactive and Vert.x reactive stacks. Because Panache acts as a layer over Hibernate ORM, it adheres to standard JPA behavior: a SELECT query without a defined limit is translated into SQL that requests the entire result set. Neither the reactive engine nor the REST layer injects a hidden default limit to protect the application from large datasets.
Because there is no global safety limit, omitting pagination on large tables can lead to OutOfMemoryError (OOM) as the JVM attempts to load the entire result set into the heap. This is particularly critical in reactive stacks where blocking the event loop with massive data processing can degrade system performance.
To verify the absence of a default limit in your specific environment, follow these steps:
application.properties: quarkus.hibernate-orm.log.sql=truerepository.listAll()) against a table containing more than 1,000 records.LIMIT or TOP clause appears in the generated SQL, the query is unbounded.Diagnostic Note: If you are seeing truncated results despite not setting a limit, please specify if you are using a custom QueryInterceptor or a specific database proxy (such as a cloud-managed SQL gateway) that may be enforcing limits outside of the Quarkus application.
Use comments to ask for clarification. Post a solution as an answer.
5,380 reputation · 30 Nov 2023, 12:54 UTC
One useful distinction: RESTEasy Reactive can stream the HTTP response, but that does not translate into a database LIMIT. For recent Quarkus 3.x Hibernate ORM/Panche releases, if no Page is supplied, the generated SQL remains unbounded. The web layer affects serialization and backpressure, not row selection.
The same applies to Vert.x reactive routes. A reactive pipeline may process rows incrementally, but the result set is still unbounded unless you call .page() or apply an explicit query limit. Backpressure can reduce buffering; it does not add a SQL row cap.
LIMIT or FETCH FIRST confirms the stack is not injecting a cap.Page.of(0, 0) separately. Do not assume it means “no limit”; zero-size semantics can be version- and dialect-sensitive.