Re: SQL to Linq - Left, Right and Inner Joins

Tech-Archive recommends: Speed Up your PC by fixing your registry




"Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@xxxxxxxxx> wrote in message
news:uIv2j0A4IHA.2336@xxxxxxxxxxxxxxxxxxxxxxx

(...)
Though there are still differences in performance. Take these two:

select c.*
from customers c cross join orders o
cross join employees e cross join [order details] od
where
c.CustomerId = o.CustomerId
and
e.EmployeeId = o.EmployeeId
and o.OrderId = od.OrderId

vs.
select c.*
from customers c inner join orders o
on c.CustomerId = o.CustomerId
inner join employees e on e.EmployeeId = o.EmployeeId
inner join [order details] od on o.OrderId = od.OrderId

THe server trace shows that the duration of the query first query is much
longer than the second query.




The query plans are the same. The tracer may show that the second took less
time simply because some data was still in the data cache!

Look at the execution plans! they are both the same!



Vanderghast, Access MVP


.



Relevant Pages

  • Re: SQL to Linq - Left, Right and Inner Joins
    ... select distinct c.* from customers c cross join orders o ... Specifying a query with different constructs and then relying on the optimizer to make the best of it isn't optimal and will likely fail in some situations. ... Well you can easily add where clauses to each effective side of a join in LINQ: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Query training -- Complex queries
    ... Second, let's take a little example, you could run in you Query Analyzer: ... from authors inner join authorsx ... A cross join that does not have a WHERE clause produces the Cartesian ... The size of a Cartesian product ...
    (microsoft.public.sqlserver.server)
  • Re: Help writing a query
    ... >> in the query designer. ... The key to it is that it's a CROSS JOIN ... > between groups and scenarios yielding the 15 rows in my example above. ... > ending up with syntax errors. ...
    (microsoft.public.access.queries)
  • Re: Please need help with Cross Join query
    ... It sounds to me like you want a cross join, ... union all ... >The problem with this query: ... >from SIZES s full join ...
    (microsoft.public.sqlserver.programming)
  • Re: Help with query from FoxPro
    ... "DAVID" wrote: ... Then join to the query instead of joining to tk_ctrl. ... you want to avoid having a cross join ... When you design your own tables, put a dummy join field ...
    (microsoft.public.access.queries)