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?
28775 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.
No question comments on this page.