I'm using the default DO4 project template, which comes with MyEntity. I simply renamed MyEntity to Customer, and did a session.Query.All<customer>().Count().
Why does DO use subselects?
Why not simply SELECT COUNT_BIG(*) FROM Customer?
It does this for non-count queries, too, unless they are projected to DTOs... in which case it uses normal queries (i.e. doesn't use subselects).
asked Mar 05 '11 at 04:53
Actually, this is not a subselect. Subselect is executed for every source record while here is just select from select.
And the answer is: such behavior is by intent, it is the result of generic layered query translation architecture: operations are applied to the result of previous operation execution (here COUNT operation is applied to all records from the
In case you are suspicious about the possible performance lack, I could state that the performance of these 2 queries as well as execution plans are identical.
answered Mar 05 '11 at 05:36