How to Unforce a Query Execution Plan in SQL Server

When you’ve forced an execution plan in SQL Server’s query store and later want to allow the optimizer to choose plans freely again, you’ll need to unforce the plan. You might want to do this because you’ve fixed the underlying issue or the forced plan is no longer optimal. Whatever the reason, the solution is straightforward and easy.

Read more

What is a CRDT?

A CRDT (Conflict-Free Replicated Data Type) is a special type of data structure designed for distributed systems that guarantees multiple replicas of data will eventually converge to the same state without requiring coordination between nodes. Even when different users simultaneously modify the same data in different locations, CRDTs automatically resolve conflicts in a mathematically consistent way that ensures all replicas eventually agree.

The main insight behind CRDTs is that certain operations can be designed to be commutative, meaning the order in which you apply them doesn’t matter. If operation A followed by operation B produces the same result as operation B followed by operation A, you can apply updates in any order and still reach the same final state. This property eliminates the need for complex conflict resolution logic.

Read more

Generating Staggered Dates with SQL Server Window Functions

SQL Server’s window functions open up some creative possibilities when you need to work with dates. One interesting pattern involves pairing DATEADD() with ROW_NUMBER() to automatically generate sequential dates based on your query results.

This technique gives you a flexible way to calculate dates dynamically without hardcoding values or maintaining separate date tables. This can be useful for doing things like building a scheduling system, creating test data with realistic timestamps, or just spacing events across a timeline.

Read more

What is Eventual Consistency?

Eventual consistency is a consistency model used in distributed databases where data updates don’t immediately propagate to all copies, but given enough time without new updates, all copies will eventually become identical. When you write data to one location in the system, other locations might temporarily see old data, but they’ll all catch up eventually. This usually happens within milliseconds or seconds (although it can be longer during network issues or node failures).

This approach contrasts with strong consistency, where every read is guaranteed to return the most recent write immediately. With eventual consistency, the system prioritizes availability and performance over immediate accuracy. You’re accepting that different parts of your database might temporarily disagree about the current state of the data in exchange for faster operations and better fault tolerance.

Read more

Understanding Locks in SQL Server

If you’ve ever wondered why your database queries sometimes seem to wait around doing nothing, or why two users can’t update the same record at the exact same moment, you’re dealing with locks. In SQL Server, locks are the fundamental mechanism that keeps your data consistent and prevents the chaos that would ensue if everyone could modify everything simultaneously.

Read more

What is a Columnstore Index?

A columnstore index is a type of database index that stores data by column rather than by row. Traditional indexes (and tables) store data row-by-row, where all the values for a single record are kept together. Columnstore indexes flip this around, storing all values from a single column together instead.

This might seem like a small difference, but it fundamentally changes how the database reads and processes data. Columnstore indexes are designed for analytical queries that scan large amounts of data, performing aggregations, calculations, and filtering across millions or billions of rows.

Read more

What is Vertical Scaling?

Vertical scaling is the practice of increasing the capacity of a single server by adding more resources to it. For example more CPU power, RAM, storage, or faster hardware. Instead of adding more machines to handle increased load, you make your existing machine more powerful.

In database contexts, vertical scaling means upgrading your database server to more powerful hardware so it can handle more queries, store more data, and process transactions faster. It’s the most straightforward way to improve database performance.

Read more