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
SQL Injection
What is SQL Injection? A web security vulnerability where unvalidated user input executes unauthorized commands directly in a database.
Database Backup
What is a Database Backup? A scheduled backup copy that lets you restore your site's critical data after technical failures or accidental deletion.
Database
What Is a Database: A system organized into tables and records for storing, retrieving, and updating large volumes of information.
MySQL
What is MySQL? An open-source relational database management system widely used to store and manage data for WordPress and web apps.
Redis
What is Redis? An open-source in-memory RAM data store used as an object cache to accelerate repetitive database queries in WordPress.
Query (SQL Query)
What is an SQL Query? An instruction sent to a database to search, filter, insert, update, or delete stored records quickly and accurately.
NoSQL Database
What Is a NoSQL Database: A non-relational storage system that uses documents, key-value pairs, or graphs instead of fixed tables.
Resources and Support
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.
