JavaScript is required for the interactive terminal. The essential portfolio information remains available below.
Static Markdown articles about building dependable software.
An index is not a performance button
How to investigate a slow query, understand composite index order, and review the execution plan before changing the database.
When a query takes seconds to return, one solution often comes to mind immediately: add an index. Sometimes it works. In other cases, response time barely changes, or reads improve while writes become more expensive.
The goal is not to avoid indexes. It is to understand which part of data access is costly, which queries need support, and what trade-off the change introduces.
Start with the query, not the index
Imagine a people table with millions of rows. A search screen looks up someone by first and last name:
sql
SELECT id, firstname, lastname
FROM people
WHERE lastname = 'Machado'
AND firstname = 'João';
An index on firstname alone may help the database find candidate rows, but it still has to check the last name. If that first name appears in many rows, the database may read and discard a large number of them. Depending on the table size, value distribution, and available statistics, the optimizer may even prefer a sequential scan.
That does not make a sequential scan inherently bad: for a small table or a filter that returns a large share of its rows, reading the whole table can be cheaper.
Composite index order matters