When we write a query using Lambda expression or equivalent one, the DataContext converts it to the SQL expression which is consumed by data base and we get the result set. However the Query Optimizer sitting at data base takes the input query and subsequently tries to optimize it. Since the input query plays a bigger role in the optimization process and on the other hand having less control on conversion of lambda expression to SQL expression (thru DataContext), clearly raise the issue of the obtaining the best query plan or optimization for the Lambda expression we write.
Do we have some kind of control on this or how is this situation being tackled
Thanks
-Sachin
< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Less control over Query optimization process because of lack of control on conversion of lamda expression to SQL Expression
EdenR
You can take the expression tree and build your own query generator. As we make more progress, you will see more documentation about expression trees.
Even in most databases, optimizer kicks in after the binder has done its work. Much of what DLinq does is related to binding using mapping metadata and translating across the O-R divide. Most existing query optimization techniques really apply to the output of DLinq query translator. They are also quite different from the common compiler-optimization techniques that could be applied to an expr tree.
While such optimizations are conceivable, I would be curious to hear if you have a concrete set in mind.
Thanks.
Dinesh
Lapostal
Are you thinking of hinting the database
One thing to keep in mind is the scale of benefit an optimization may provide in a reasonably-constructed database. If, when the server already has indexes, etc applied, the query produced by DLinq is half as fast as a non-arcane query, there is obviously a problem. Conversely, if working black magic (as the DBA at a former employer called it) produces a tuned query that gains 3-5% over one produced by DLinq, then the effort better spent elsewhere.
The "best" strategy is often one that is specific to the situation and database in particular, and not generally useful outside of that scope. For that, Dinesh's comment about making your own database provider is probably the best approach I could suggest. At the moment, however, that is a non-trivial endeavor.
On the other hand, there are places where the queries produced by DLinq are obviously messy ("NOT NOT", for example), and those should probably be cleaned up.
jradi
mul2006
Alvin, You may want to take a look at any of a number of projects extending LINQ to other providers. Our upcoming Linq In Action (www.linqinaction.net) book will demonstrate how to use the expression trees to consume Amazon web services. There are a number of other implementations out there including LINQ to Flicker and LINQ to NHibernate.
Jim Wooley
http://linqinaction.net
http://devauthority.com/blogs/jwooley