---
title: Easy database indexing strategies
url: "https://aaronfrancis.com/videos/easy-database-indexing-strategies"
path: "/videos/easy-database-indexing-strategies"
type: video
author: Aaron Francis
published: 2023-10-26
topic: Databases
keywords: [functional indexes, generated columns, database indexing, mysql, planetscale, json indexing, composite indexes, case insensitive search, data normalization, text indexing, date indexing, calculated fields]
youtube_url: "https://www.youtube.com/watch?v=IcIkjfXoHV4"
chunked: true
full_bytes: 36917
section_count: 13
full_url: "/videos/easy-database-indexing-strategies/full.md"
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

# Easy database indexing strategies

## Sections (36.1 KB full document — follow any link to read verbatim)

This page is long enough to hit agent truncation cliffs if fetched all at once. Pick the section matching your question below to read it 100% verbatim (< 35 KB each), or open the [full unsplit document (36.1 KB)](/videos/easy-database-indexing-strategies/full.md).

### 1. Functional indexes and generated columns (00:00–00:46 · 1.0 KB)
Functional indexes and generated columns are advanced techniques to speed up queries beyond single or composite column indexes, with ten examples to follow.
Keywords: `functional indexes`, `generated columns`, `functional`, `database indexes`, `generated`, `columns`, `examples`, `index`
[Read section 1 verbatim](/videos/easy-database-indexing-strategies/sections/1-functional-indexes-and-generated-columns.md)

### 2. What is a functional index? (00:46–02:30 · 1.8 KB)
Functional indexes put an index on the result of an expression or function rather than a column, enabling indexing of calculations, transformations, and JSON extractions; MySQL 8.0.13+ supports functional indexes natively, earlier versions use generated columns as a workaround.
Keywords: `functional index`, `index`, `functional`, `functional indexes`, `column`, `database indexes`, `generated columns`, `mysql`
[Read section 2 verbatim](/videos/easy-database-indexing-strategies/sections/2-what-is-a-functional-index.md)

### 3. Example 1: Indexing the end of a string (02:30–05:27 · 3.1 KB)
LIKE queries with leading wildcards (e.g., '%domain.com') don't use standard indexes, but a functional index on SUBSTRING_INDEX can extract and index just the domain part for efficient lookups.
Keywords: `string`, `database indexing`, `functional index`, `index`, `email`, `functional`, `normal index`, `email column`
[Read section 3 verbatim](/videos/easy-database-indexing-strategies/sections/3-example-1-indexing-the-end-of-a-string.md)

### 4. Example 2: Case sensitive indexing (05:27–07:49 · 2.4 KB)
Wrapping indexed columns in functions like LOWER() obfuscates the index, but a functional index on LOWER(first_name) can serve queries that unnecessarily apply LOWER when the column's collation is already case-insensitive.
Keywords: `case sensitive`, `sensitive indexing`, `orm`, `database indexing`, `sensitive`, `index`, `case-insensitive search`, `string`
[Read section 4 verbatim](/videos/easy-database-indexing-strategies/sections/4-example-2-case-sensitive-indexing.md)

### 5. Example 3: Indexing a TEXT or BLOB (07:49–09:57 · 2.1 KB)
TEXT/BLOB columns are too large to index directly, but a functional index on MD5(url) enables indexed exact-match lookups on large text fields while avoiding false positives via secondary full-text validation.
Keywords: `text`, `mysql`, `database indexing`, `blob`, `url`, `strict equality`, `functional index`, `text column`
[Read section 5 verbatim](/videos/easy-database-indexing-strategies/sections/5-example-3-indexing-a-text-or-blob.md)

### 6. Example 4: Indexing a date part (09:57–13:05 · 3.3 KB)
Extracting and indexing date parts like YEAR() or MONTH() avoids obfuscating a birthday column's index; alternatively, unwrapping the function (using BETWEEN with date ranges) is preferable when possible.
Keywords: `date part`, `date`, `database indexing`, `nineteen eighty-eight`, `functional index`, `index`, `birthday`, `table`
[Read section 6 verbatim](/videos/easy-database-indexing-strategies/sections/6-example-4-indexing-a-date-part.md)

### 7. Example 4.5: Indexing a date part, semantically (13:05–16:42 · 3.8 KB)
Generated columns like is_weekend add semantic clarity to complex expressions (e.g., WEEKDAY() = 1 or 7) while preserving MySQL's ability to use the underlying formula's functional index.
Keywords: `date part`, `mysql`, `date`, `database indexing`, `semantically`, `generated columns`, `index`, `future self`
[Read section 7 verbatim](/videos/easy-database-indexing-strategies/sections/7-example-45-indexing-a-date-part-semantically.md)

### 8. Example 5: Grouping by functional index (16:43–19:35 · 2.7 KB)
A generated column bucket can group time-series logs into hourly buckets via DATE_FORMAT, then an index on that column accelerates GROUP BY aggregations.
Keywords: `functional index`, `index`, `grouping`, `functional`, `generated columns`, `limit ten`, `alter table`, `table logs`
[Read section 8 verbatim](/videos/easy-database-indexing-strategies/sections/8-example-5-grouping-by-functional-index.md)

### 9. Example 6: Calculating age (19:36–21:22 · 1.6 KB)
Functional indexes and generated columns must be deterministic (same output every run), so TIMESTAMPDIFF(YEAR, birthday, NOW()) fails because NOW() changes; RAND() and other non-deterministic functions also cannot be indexed.
Keywords: `calculating age`, `calculating`, `functional index`, `index`, `functional`, `function`, `data`, `told`
[Read section 9 verbatim](/videos/easy-database-indexing-strategies/sections/9-example-6-calculating-age.md)

### 10. Example 7: Data normalization (21:22–24:07 · 2.7 KB)
A stored generated column using ST_POINT_FROM_TEXT() normalizes vendor latitude/longitude data into MySQL's native geometric point type, enabling spatial indexing.
Keywords: `data`, `data normalization`, `mysql`, `normalization`, `select star`, `generated columns`, `column`, `geometric point`
[Read section 10 verbatim](/videos/easy-database-indexing-strategies/sections/10-example-7-data-normalization.md)

### 11. Example 8: Indexing a raw calculation (24:07–26:30 · 2.4 KB)
Virtual generated columns like price_per_square_foot = CEILING(price / square_footage) are stored in the index structure, not the column, enabling fast range queries without disk storage overhead.
Keywords: `calculation`, `raw calculation`, `database indexing`, `raw`, `square foot`, `price per`, `per square`, `generated columns`
[Read section 11 verbatim](/videos/easy-database-indexing-strategies/sections/11-example-8-indexing-a-raw-calculation.md)

### 12. Example 9: Combining multiple statuses, and composite indexes (26:31–31:16 · 4.6 KB)
A generated is_visible column wraps multiple business-logic conditions (published, deleted, archived, spam status), enabling composite functional indexes that significantly reduce key size for multi-condition WHERE and ORDER BY clauses.
Keywords: `composite indexes`, `composite`, `database indexes`, `combining multiple`, `multiple statuses`, `combining`, `multiple`, `statuses`
[Read section 12 verbatim](/videos/easy-database-indexing-strategies/sections/12-example-9-combining-multiple-statuses-and-comp.md)

### 13. Example 10: Indexing JSON parts (31:16–36:00 · 4.7 KB)
A generated column extracting a JSON key (e.g., JSON_UNQUOTE(data->'$.email')) allows indexed lookups on specific JSON properties without indexing the entire blob.
Keywords: `indexing json`, `json`, `mysql`, `example 10`, `json parts`, `database indexing`, `json data`, `json blob`
[Read section 13 verbatim](/videos/easy-database-indexing-strategies/sections/13-example-10-indexing-json-parts.md)

---

## Related on aaronfrancis.com

- [Faster database indexes (straight from the docs)](/videos/faster-database-indexes-straight-from-the-docs) *(Video · 2023-09-29 · shared: composite indexes, functional indexes, mysql)*
- [MySQL for Developers with Aaron Francis](/podcast/mysql-for-developers-with-aaron-francis-n6unbd) *(Podcast · 2023-04-04 · shared: mysql, planetscale, generated columns)*
- [You don't need NoSQL (use MySQL)](/videos/you-dont-need-nosql-use-mysql) *(Video · 2023-11-03 · shared: mysql, json indexing, generated columns)*
- [MySQL for application developers](/about/speaking/mysql-for-application-developers) *(Talk · 2023-04-20 · shared: mysql, planetscale, database indexing)*
- [You don't always need JOINs](/videos/you-dont-always-need-joins) *(Video · 2023-11-22 · shared: query optimization, mysql, planetscale)*

## Relevant Resources from Aaron Francis

- **[MySQL for Developers](https://databaseschool.com)** (overview on site: [/courses](/courses)): Full video course covering MySQL indexing, deferred joins, pagination, query plans, and schema design for application developers.
- **[Mastering Postgres](https://databaseschool.com)** (overview on site: [/courses](/courses)): Deep-dive video course on PostgreSQL indexing, query performance, JSONB, full-text search, locking, and production operations.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `functional indexes` ([F-G](/llms/keywords/f-g.txt)), `database indexing` ([D-E](/llms/keywords/d-e.txt)), `mysql` ([M-N](/llms/keywords/m-n.txt)), `planetscale` ([O-P](/llms/keywords/o-p.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
