On Mon, Jun 21, 2010 at 10:02 AM, Publius Maximus <[email protected]> wrote: > 2010/6/21 Ricardo Aráoz <[email protected]>: >> On 19/06/10 18:51, Publius Maximus wrote: >>> This is the magic behind sending a LINQ expression from a client to a >>> SQL server, and the code actually being executed on the server side. I >>> don't mean like a typical SQL query, where it sends text that needs to >>> be parsed, in this case, it's the fully "ready to execute" >>> representation that gets immediately executed. >>> >>> >> >> You mean the difference is the sql query gets parsed in the client? Or >> the coder has to parse it? What's the big advantage of that? Never had >> problems with an sql query being parsed in the server. >> And what is a "ready to execute representation"? Do you mean the server >> does not get to decide the strategy of the query based on resources and >> such? > > Because SQL server since 2005 is built on the CLR, it can take the > expression tree created by the LINQ query -- already pre-compiled on > the client -- and execute it more or less as-is on the server. ---------------
At a UG meeting a while back I asked this Q and the presenter said that Linq submission back to the DB was better organized to make the PLAN for the query work better. The engine will always have to determine the optimal plan, the Linq sysntax is just constructed to save a set of steps there. The plan is always assessing data volume and best index to use. > This isn't to suggest there was a problem with parsing SQL on the > server side, though precompiled queries defined on the server side are > known to execute better than their text-based equivalents coming > dynamically from the client side. The idea is that LINQ queries take > advantage of that approach but does not limit the precompilation to > the server side. ---------------------------- Not true in any 2000 product. A SP which is not precompiled, just held in an object for resuse, still needs a plan. Yes that plan goes to the plan cache and will be used there depending on data volume changes. For data volume changes think of financial trading of stock buy and sell orders or even eBay bids. A tremendous velocity over a day. You may be getting inserts on the order of 10,000 per second. > It's just a nifty aspect of the LINQ implementation, the concepts for > which were invented by the folks who invented Haskell's Monad and > related abstractions (of whom Erik Meijer, now at MS, was a key > player). > > The idea of passing code around as data is the main innovation, and it > is already proving important for multicore and distributed computing > in practice. ------------------ I am trying to take this project I am on now and make 90% of all my Linq in lambda style just so I get more comfortable with it. In general I do more linq work with objects in ram then requests against the db. -- Stephen Russell Sr. Production Systems Programmer CIMSgts 901.246-0159 cell _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[email protected] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

