SQL Queries Tuning by Brent Ozard

Hi, today I want to share with you training that I get from one colleague today. This is available at Watch Brent Tune Queries [Video] I have to said that I really enjoy this presentation and charisma of the presenter. And I learn a lot from his presentation. So I decided to share it with you. There is one thing I cannot agree with my experience which is changing requirements to tune up queries. I never ask do you really need this? And I always tune up queries to said this is exactly the same content but I am giving you it faster with this T-SQL code changes, or non-functional indexes changes, of course. Let me know if you like this presentation. Enjoy!

p ;)

One Reply to “SQL Queries Tuning by Brent Ozard”

  1. I am not MCM, but I am wondering how fast is below query? ;)

    ;with
    VotesStats_up as
    (
      select PostId, cnt = count(*) from Votes m where m.VoteTypeId = 2 group by m.PostId
    ),
    VotesStats_dw as
    (
      select PostId, cnt = count(*) from Votes m where m.VoteTypeId = 3 group by m.PostId
    ),
    VotesStats as
    (
      select
        PostId = p.Id,
        up = isnull(up.cnt, 0),
        down = isnull(dw.cnt, 0)
      from Posts p
      left outer join VotesStats_up up on p.Id = up.PostId
      left outer join VotesStats_dw dw on p.Id = dw.PostId
    )
    select top 100
      p.id as [Post Link], v.up [Up], v.down [Down]
    from VotesStats v
    inner join Posts p on v.PostId = p.Id
    where down > (up * 0.5) and p.CommunityOwnedDate is null and p.ClosedDate is null
    order by up desc
    

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.