Hi Thang.
How did you come to that conclusion? I ask this because, if you were watching at the debugger variables, then the values will not be optimized. But if no debugger is attached, then the aggregates will be optimized.
Because of that, in practice, there's no easy way to observe the optimizations taking place. The easiest way to observe it is to compare two screens, one with the optimization, and another without the optimization. Here's a recipe for doing that:
1. Create two entities, A and B. B should have a foreign key to A, and also an attribute of type binary data. We will use the binary data to populate B with large files, so that we can observe the optimization by comparing the performance between the two queries.
2. Populate the two entities. Scaffolding the entities might help to create the screens to populate them. Create a few entries in A, and a few entries of B with relationships to A. Make sure to upload large files (a few MB each) to all instances of B.
3. Reference the BinaryDataSize action comes from BinaryData extension. We will use this to read the binary and display some values on the screen.
4. Create a screen without the optimization. For this, place an aggregate with A JOIN B on the preparation. Then display the results in a table records, and add a column to display the size of the binary field.
5. Create a screen with the optimization. For this, place the same aggregate with A JOIN B on the preparation. Then, assign the aggregate's result to a variable with type List of A. Then display this variable in a table records.
6. Compare the performance of both screens, without running the debugger. If you have access to the database, you can also check the executed SQL, or check how many MB were transferred in each screen.
7. Conclusion: given that the aggregate is the same in both screens, the difference in performance can only be explained if the executed queries were different, and the second screen did not include the binary column in the SQL. We are, obviously, assuming that executing the BinaryDataSize function (which is the only differences between the screens) has negligible performance impact.