Official horizontal UNEMPRENDE logo with dark text on a light background
Black Friday

Index (Database Index)

What is a Database Index: a structure that speeds up SQL searches and filters without having to scan the entire table row by row.

What is Index (Database Index)?

A database index It is an auxiliary structure associated with one or more columns of a table that allows the database engine to locate specific records without scanning the entire table row by row. It works like the alphabetical index in a technical book: it takes you directly to the exact page instead of having to read through the entire volume.

How a Index Can Speed Up Your Website's Performance

Imagine an auto parts store in Bogotá that handles 80,000 orders and 150,000 line items in MySQL. If a customer queries their history by ID number and that column is not indexed, the engine performs a full table scan (full table scan), reading each row one by one.

With an appropriate index (typically structured as a B-tree), the query (SQL query) It finds the exact location in just a few steps, reducing execution time from several seconds to just a few milliseconds and freeing up processor resources for other buyers.

Most Common Types of Indexes and When to Use Them

Not all indexes serve the same purpose within a table:

  • Primary key (PRIMARY KEY): It uniquely identifies each record and physically organizes the data in engines such as InnoDB.
  • Single Index (UNIQUE): In addition to speeding up searches, it prevents critical values—such as user email addresses or SKU codes—from being duplicated.
  • Composite Index: Combine two or more columns in a specific order to optimize combined filters, such as searching for orders by customer and date.
  • Full-text index (FULLTEXT): Speeds up keyword searches within long product or article descriptions.

The Balance Between Read Speed and Write Cost

Creating indexes on absolutely every column is a common mistake. Every time you insert, update, or delete a record, the database must also update all its indexes, which consumes disk space and slows down write operations.

The recommended practice is to index the columns commonly used in clauses WHERE, JOIN y ORDER BY, verifying the implementation plan with EXPLAIN as part of your comprehensive strategy for Web Speed Optimization (WPO).

More terms related to Databases

See More Terms

Resources and Support

We're Here for You Every Step of the Way

We offer a variety of resources to help you become familiar with and understand your resources and opportunities, and to enjoy the benefits of having a digital infrastructure. In addition, we have social programs to support startups and projects with exclusive benefits.