Optimized in debugger?

Optimized in debugger?

  
So when I am debugging, as far as the result from an aggregate, items such as "count" are listed as "optimized".  What exactly is this showing?  I would like to be able to see the actual count of the aggregate list.  Probably a stupid question but what am I missing?
Jason -

Because of the way some things involving DB access are handled, the debugger can't show you some query details because they don't exist yet/haven't been retreived/haven't been calculated. The .Count is one of those. :(

J.Ja
Justin - even if this is "after" the aggregate in the flow?  I am not arguing that it doesn't work, but that doesn't make sense.
Jason -

Yes. For example, when a query is executed, not all of the results come back from the DB, it retreives them in groups ("paging"), which is why you can't see all results (says "optimized"), just the current result. Furthermore, the paging doesn't even begin until you start iterating over the results (it's a kind of lazy evaluation to save roundtrips to the DB until absolutely needed).

When you use the .Count of a query in code, it re-runs the query substituting COUNT(*) (or something similar) for the column names to get the true .Count, it isn't counting the actual rows returned... that's .Length, and calling it forces the query to pull and page through all results in the DB at once to fill the results list.

So those values aren't visible because of the optimizations that the system does at run time to make things run faster and consume fewer resources... though one could argue that if the debugger is on, those optimizations should be turned off to expose that information.

J.Ja