SQL Server - performance for filtering using LEFT JOIN ON condition versus WHERE condition

时间:2017-08-30 20:19:02

标签: sql-server performance join left-join

I have a query that was performing slowly that looked something like this:

#top-background-flag {
  border-top: 2px solid #C2C2C2;
  background: linear-gradient(
    to bottom right,
    #5DCAD3 50%,
    transparent 50.5%
  )
  no-repeat bottom, /* bottom part */
  linear-gradient(100deg, #5DCAD3, #5DCAD3) no-repeat top;
  /* top portion */
  padding-bottom: 3.5rem;
  border-bottom: 2px solid #C2C2C2;
  background-size: 100% 3rem, 100% calc(100% - 3rem)
}

The PlayerTeam table has a large numer of records (ie. 30 million)

When I modified the query to have the condition on the left join instead of the where clause, then the query peformed much better.

<div id=top-background-flag>
  A fun title
</div>

Is this a correct optimization and is the peformance improvement expected? I read that this shouldn't matter when using an inner join, but for a left join it seems to make a difference.

Which sql query is faster filter on join criteria or where clause

0 个答案:

没有答案