How Database Indexes Work

How Database Indexes Work

How an index turns a slow full table scan into a fast lookup

What you'll learn

  • What a full table scan is, and why it gets slow
  • What an index is, and how a B-Tree finds a row fast
  • What indexes cost on writes and disk
  • Which columns to index, and checking with EXPLAIN

In this video, we'll look at why a query that was fast with 1,000 rows can take seconds with 10 million, and how database indexes fix it. We'll cover full table scans, B-Tree indexes, how indexes speed up lookups, and why adding too many indexes slows down writes.

We'll also look at how to create an index, which columns to index, and how to use EXPLAIN to see whether your database used an index or scanned the whole table.

More videos

32 short explainers so far, with more on the way

View all videos

Join the Community

roadmap.sh is among the top 10 most starred projects on GitHub and is visited by hundreds of thousands of developers every month.

Top 10 out of 28M!

371K

GitHub Stars

Star us on GitHub
Help us reach #1

+90kevery month

+3.2M

Registered Users

Register yourself
Commit to your growth

+2kevery month

52K

Discord Members

Join on Discord
Join the community

RoadmapsGuidesFAQsYouTube

roadmap.shby@nilbuild

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

© roadmap.sh·Terms·Privacy·

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.