Most likely, that in the database SQL browser you are only seeing a subset of the whole ResultSet while, in Hibernate, the whole ResultSet is being traversed and fetched into your application.
Just as we explained in this
Performance Tuning Guide, there is absolutely no reason to ever fetch tons of data in your data access layer. In fact, that's an Anti-Pattern.
Therefore, you have multiple options:
1. Either you're doing the processing in the DB so that you don't have to pay the price of extracting large amounts of data and serialize them over the network
2. You can still do the processing in the application, but you need to operate on small batches at a time.
3. If you're sending the ResultSet to the UI, then pagination is mandatory since you can't even display tons of data to the user. Not to mention mobile clients.