Press "Enter" to skip to content

Day: August 28, 2026

Working with Vectors in Python

Bala Priya C avoids the loops:

In this article, you will learn how to think in terms of vectorized operations using NumPy, replacing slow Python loops with efficient array-level computations.

Topics we will cover include:

  • Why Python loops are slow for numeric data and how NumPy’s C-backed engine addresses this.
  • How to apply element-wise operations, boolean masking, and broadcasting to eliminate common loop patterns.
  • How to handle multi-condition branching and axis-based aggregation entirely with NumPy functions.

This is one of those places in which people with database development backgrounds can end up understanding the topic more intuitively than loop-heavy structured programming developers. And depending on how large the loop is and how complex each operation is, there can be a significant performance improvement in applying functions over a vector versus in a loop. It’s part of why matrix operations tend to be much faster than nested loops.

Leave a Comment

The Pain of Residual Predicates

Brent Ozar has a new animation:

If we modify our query a little by selecting all of the columns instead of just Id and Location, then we have to do a Key Lookup, like we talked about in the How to Think Like the Engine class. For each person who lives in Helsinki, we have to look up their row in the clustered index in order to fetch all the columns we need. That’s not really a big deal, though, as long as a relatively limited number of people live in Helsinki. Like I wrote in that post, the index seek + key lookup is essentially two index seeks: one into Helsinki, and then one seek (for each Helsinki resident) on the clustered index, by their Id.

However, let’s add a little more complexity to the query:

Click through for a scenario in which a more selective query can result in worse performance than a less-selective variant.

Leave a Comment

Further Thoughts on the SSMS SQL Formatter

Chad Callihan takes another look:

I posted a few months ago about the latest SQL Server Management Studio updates, including a preview of their SQL Formatter. SSMS 22.9.0 was released a few weeks ago and called out some SQL Formatter improvements on the release announcement, so I thought it would be worth taking a fresh look to see how things are moving along.

Click through for Chad’s current thoughts. The big challenge with a good SQL formatting tool is that it be adaptable to somewhat complex formatting standards. If the tool can’t do what your team has agreed on, then the tool’s not going to cut it for more than occasional personal use.

Leave a Comment

Understanding the DiskANN Algorithm

Mala Mahadevan digs into an algorithm:

DiskANN is meant to help with searching a billion-vector dataset from a single machine using SSDs.

Microsoft Research’s original work demonstrated a billion-point index on a workstation with 64 GB of RAM and an SSD, while targeting high recall and low query latency. Before we get to ‘why ssd’ and details of storage, we need to understand the basics of vector search and underlying terminologies.

Click through for a depiction of the paper and quite a few examples of how the mechanisms work.

Leave a Comment