Tag: internals

  • OR predicates and Indexes

    OR predicates and Indexes

    In this post, we will look at how SQL Server accesses indexes when an OR predicate is used. For this demo, I am going to use the Stack Overflow Database. I am using the large 2024 version provided under cc-by-sa 4.0 licence from Stack Exchange Data Dump and running in compatibility level 160 on a…

    Keep reading

  • #tsql2sday #200

    #tsql2sday #200

    This post is my first T-SQL Tuesday post since starting the blog a couple of months back. T-SQL Tuesday was originally set up by Adam Machanic, original creator of the essential sp_whoisactive stored procedure. The concept is that once a month, a different host puts out an invitation to the community for bloggers to write…

    Keep reading

  • SQL Server – Working Smarter, Not Harder

    SQL Server – Working Smarter, Not Harder

    Back in my university days, a lecturer of mine would say how programmers are experts in “creative laziness” He was referring to practices such as using methods and classes in C# – constructs that mean as a developer, you follow the DRY (Don’t Repeat Yourself) ethos – you are saving yourself time by writing things…

    Keep reading

  • SQL Server – Working Smarter, Not Harder (Again)

    SQL Server – Working Smarter, Not Harder (Again)

    In the last post we talked about the concept of creative laziness and how SQL Server’s query optimizer notices when the user has asked for something that requires no actual work due to a logical contradiction. In this post, we’ll look at another example of where the optimizer works smarter not harder and can reduce…

    Keep reading

  • Physical Joins – Merge Join

    Physical Joins – Merge Join

    In this series, we’ve been looking at the internals of physical joins – the operations SQL Server does behind the scenes to satisfy the logical joins written in our declarative T-SQL. So far, we’ve looked at nested loop joins and hash joins, and in this final post, we’ll look at the merge join. The Algorithm…

    Keep reading

  • Physical Joins – Nested Loop

    Physical Joins – Nested Loop

    This post is the first in a short series about physical join types. What do I mean by physical join types? What we normally consider to be a join – INNER / [LEFT|RIGHT] OUTER / FULL join are logical join types, they are the joins we use to describe the query results in our declarative…

    Keep reading

  • Physical Joins – Hash Join

    Physical Joins – Hash Join

    In the previous post in this series, we looked at the nested loop operator which we saw was useful when there is a small set data and a second set of sorted data. In this post, we’ll look at what is often considered the workhorse of physical join operators – the hash join. The hash…

    Keep reading

  • SQL Server Execution Plans Explained

    SQL Server Execution Plans Explained

    In these articles, you will see me reference execution plans a lot – talk about them, provide screenshots etc. I assume that the reader has some level of knowledge about what an execution plan is, how to view them and how to understand them. This post is aimed at those readers who do not have…

    Keep reading

  • More on Execution Plans

    More on Execution Plans

    In my previous post on execution plans we looked at what an execution plan is, how SQL Server creates them and why we might use them, now we’ll delve a little further. Recap We very briefly compared two SQL Server execution plans on two queries against the Stack Overflow 2010 database provided under cc-by-sa 4.0…

    Keep reading

  • Understanding SQL Server Indexes

    Understanding SQL Server Indexes

    This post follows on from the previous two about execution plans in SQL Server, in those posts I covered what an execution plan is, what they tell us and why we might need to use them. Indexes are actually nothing at all to do with execution plans but when talking about one, you often end…

    Keep reading