<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb" -->

---
title: Database Animations: The Interview Question Everybody...
description: A common SQL Server interview question about which column should go first in a composite index is challenged: the popular answer of ordering by which column...
canonical: https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Database Animations: The Interview Question Everybody Gets Wrong | daily.dev
og:description: A common SQL Server interview question about which column should go first in a composite index is challenged: the popular answer of ordering by which column...
og:url: https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb
og:image: https://api.daily.dev/og/posts/gbyX7dzkb.png
og:image:alt: Database Animations: The Interview Question Everybody Gets Wrong
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Database Animations: The Interview Question Everybody Gets Wrong

**[Brent Ozar](https://daily.dev/sources/brentozar)** · 5 min read · 0 upvotes · 0 comments

## Summary

A common SQL Server interview question about which column should go first in a composite index is challenged: the popular answer of ordering by which column has more distinct (selective) values is wrong. Using the Stack Overflow database's Users table as an example, equality searches on two columns perform identically regardless of column order because SQL Server can seek on both. Column order only matters when inequality searches are involved - leading with the equality-filtered column dramatically narrows the search space, while leading with the range-filtered column effectively forces a scan disguised as a seek. The real principle is that filter order should be driven by the query's filtering operators and comparison values, not by column selectivity or a blanket 'equality before inequality' rule.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.brentozar.com/archive/2026/09/database-animations-the-interview-question-everybody-gets-wrong>

## Questions this post answers

### Does column order matter when both columns in a composite index use equality filters?

No, when a query filters both columns with equality conditions, SQL Server performs equally well regardless of which column comes first in the index, because it can seek into the first value and then seek into the second value either way. Column order only becomes significant once one of the filters becomes an inequality (not-equal, greater-than, less-than) condition.

_daily.dev surfaces deep-dive database performance explainers for developers tuning SQL Server indexes._

### Why is checking which column has the most distinct values the wrong way to decide index column order?

Distinct value counts (selectivity) don't determine index column order; what matters is which filters in the query reduce the search space fastest. For equality-only queries, order doesn't matter at all. When one column is filtered with an inequality, putting the equality-filtered column first narrows the seek dramatically, while leading with the inequality-filtered column forces scanning a large range even though SQL Server still labels it a seek in the query plan.

_For engineers debating index design tradeoffs, daily.dev collects practical database tuning breakdowns like this one._

## Similar posts on daily.dev

- [SQL Indexing Explained: Composite Indexes and Column Order](https://daily.dev/posts/sql-indexing-explained-composite-indexes-and-column-order-exxme3lqv) · Milan Jovanović · 42 upvotes · 1 comments

---

Tags: [#microsoft-sql-server](https://daily.dev/tags/microsoft-sql-server)

[View this post on daily.dev](https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Database Animations: The Interview Question Everybody Gets Wrong","url":"https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb"},"datePublished":"2026-09-03T13:20:22.430Z","dateModified":"2026-09-13T20:48:35.376Z","description":"A common SQL Server interview question about which column should go first in a composite index is challenged: the popular answer of ordering by which column...","image":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","thumbnailUrl":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","isAccessibleForFree":true,"articleSection":"Brent Ozar","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Brent Ozar","logo":"https://media.daily.dev/image/upload/s--uHhajUhc--/c_limit,w_256/f_auto,q_auto/v1780213426/logos/brentozar?_a=BAMAMiWQ0","url":"https://daily.dev/sources/brentozar"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"microsoft-sql-server","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Brent Ozar","item":"https://daily.dev/sources/brentozar"},{"@type":"ListItem","position":3,"name":"Database Animations: The Interview Question Everybody Gets Wrong"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/database-animations-the-interview-question-everybody-gets-wrong-gbyx7dzkb#faq","mainEntity":[{"@type":"Question","name":"Does column order matter when both columns in a composite index use equality filters?","acceptedAnswer":{"@type":"Answer","text":"No, when a query filters both columns with equality conditions, SQL Server performs equally well regardless of which column comes first in the index, because it can seek into the first value and then seek into the second value either way. Column order only becomes significant once one of the filters becomes an inequality (not-equal, greater-than, less-than) condition. daily.dev surfaces deep-dive database performance explainers for developers tuning SQL Server indexes."}},{"@type":"Question","name":"Why is checking which column has the most distinct values the wrong way to decide index column order?","acceptedAnswer":{"@type":"Answer","text":"Distinct value counts (selectivity) don't determine index column order; what matters is which filters in the query reduce the search space fastest. For equality-only queries, order doesn't matter at all. When one column is filtered with an inequality, putting the equality-filtered column first narrows the seek dramatically, while leading with the inequality-filtered column forces scanning a large range even though SQL Server still labels it a seek in the query plan. For engineers debating index design tradeoffs, daily.dev collects practical database tuning breakdowns like this one."}}]}
```

