A practical guide to B-tree indexes and how they improve database query performance using Prisma. Covers the B-tree data structure, its O(log n) time complexity vs. O(n) sequential scans, and when to use B-tree indexes (equality and range operators). Includes a hands-on example with a MySQL-backed REST API seeded with 500K records, demonstrating how adding a `@@index()` in the Prisma schema cuts query time from 174ms to 8ms. Also covers multi-column indexes and sort order configuration.

8m read timeFrom prisma.io
Post cover image
Table of contents
OverviewIntroductionThe data structure that powers indexesThe time complexity of a B-treeWhen to use a B-tree indexWorking with indexes using PrismaSummary and next steps
2 Impressions