im using c# mongodb driver. in its official documentation about Lambda Expressions Projection they say:
The driver supports using expression trees to render projections.
Inherently, a lambda expression contains all the information necessary to form both the projection on the server as well as the client-side result and requires no further information.
and some lines after that, we have:
When a Find projection is defined using a lambda expression, it is run client-side.
now i'm a bit confused about Lambda Expression projection side. is it running server-side or client-side?
when i project a document using .Include() and .Exclude() methods, is it creating a server-side projection or a client-side one?
for example if i filter a Post document and i want to exclude its tags field with .Exclude() method, does the driver fetch the whole document and then exclude tags field in the application or it issues a Mongodb find() request with { tags: 0 } projection?
what is the difference between Lambda Expression projection and projecting documents using .Include() and .Exclude() when i want to find and project some documents in the aspect of projection side?
thanks.
after some research and examining both types of projection on a sample database with enabled full detailed profiling, i've found that both .Exclude() and .Include() (using Projection Builder), and single Expression projection types run on the server-side. i still dont know what is the difference between theses projection - as the official documentation says, but i solved my question and now im sure that main projection part is done on the server-side.
here are results of my researches in two different types of driver-provided projections (using hte example database and just useful parts of profiling results shown):
Projection using Expression:

Projection using Projection Builders (.Include() .Exclude()):

it seems i can just use links to pictures for now (lack of reputation!).
links to helpful docs that i've used are available in comments.
i hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With