I can set the max results on a query, but can I find what the total would have been without (Paging)
Theodore David Williams
posted 4 years ago
I am executing a query and on that query I am setting the max results I want back from the data base. How ever I still need to know what the total number of results would have been if I did not limit the query.
I think I can setup a criteria, but then I would have to but in the same info as in my query object, do I really need to create a criteria object and query the DB again to the total?
As a general database question, the main point of telling the database to just give you the top 50 results is so that it doesn't have to go through all 12,397 results. And therefore it would be completely unreasonable to expect it to produce the number 12,397 from that top-50 query.
Does that answer your question?
Also, the usual way to find out the size of a query is to use a "Select count(*) from ..." type of query. That also frees the database from having to return all 12,397 rows across the network just so that something can count the rows. But sorry, I don't know how you do that with an entity manager.