Categories
SQL

Optimising Sort Operators in Window Functions

We’re on quite a roll with window functions these past few weeks. Last week we looked at the operators we’d see in execution plans when using a window function. This week I wanted to tackle one of the more troublesome ones specifically: the Sort operator. We know that sort operators are expensive in our queries. To use […]

Categories
SQL

Anatomy of a Window Function Execution Plan

After last week’s post I got to thinking that although we’ve looked at how to implement window functions, we haven’t peeked under the hood to see how they are executed. Then what do you know, Kevin has picked up my post to provide an alternative approach. He observed that whilst his approach was more straightforward it produced a more […]

Categories
SQL

Mixing Grouping and Window Functions

We revisited window functions last week for T-SQL Tuesday. As we’re in that area there’s another example I thought was worth exploring. Can we group data whilst applying window functions in the same query? The problem For our example we’ll use the same sample data as last week. This contains sales values broken down by period, also […]

Categories
T-SQL Tuesday

T-SQL Tuesday #168 – Mature Window Functions

This month’s invitation from Steve asks us to about how window functions have made life easier for us. Before we get into that let’s have a brief recap of what window functions are for those who aren’t familiar. What are they? Window functions are like regular functions we’d use in a result set such as SUM() or MIN() but more […]

Categories
SQL

Removing the Shackles on Parallelism

Our SQL Server environments are home to many workloads. In these situations one size doesn’t always fit all when it comes to configuration. Let’s take an example. On one hand we want small, high performance, transactional processing during the day. Through the evening this could change to larger, batch processing tasks. I’ve seen the configuration […]

Categories
SQL

Deeper into Concurrency Contention

We’ve recently looked at how single threaded concurrency was handled in SQL Server and followed up last time by diving into multithreaded concurrency. This time we’re going to go a bit further with the multithreading to look more into how the contention is handled when the number of cores available doesn’t line up with our workload. We’ll also […]

Categories
SQL Server

Multithreaded Concurrency Essentials

Recently we looked at single threaded concurrency in SQL Server for workloads which only need a single core to execute. We saw how they ran at the same time with the queries effectively being round-robined on the CPU. This time out I wanted to look at how the concurrency looks when we’re working with multithreaded workloads. Setting […]

Categories
SQL Server

Demonstrating Concurrency in SQL Server

The question for today: if we have three queries – one which takes 1 second to run, one which takes 2 seconds to run, and one which takes 3 seconds to run – how long will it take to return data for the first and last query if they all start at the same time? […]

Categories
SQL

More Caring, More Sharing: Handling Datasets within Sessions

When building data solutions we’ll be handling sets of data which may need to be imported, transformed, aggregated or exported amongst other things. With more complex solutions can come a need to share this data between different areas of the process. Last week we looked at being able to share individual values within a session and […]

Categories
SQL

Sharing is Caring: Exchanging Values within Sessions

When developing application code we may be familiar with exchanging data and objects through the application. This practice is much less common in SQL due to being transactional when we consider application / OLTP workloads. There are however some times when exchanging values between code in the same session which is what we’ll start to […]