EasyEnv
PostgreSQL
IntermediateLesson 8 of 1435 min · hands-on

Indexes

Part of the PostgreSQL course

The query worked fine on your laptop with two hundred test rows. In production, against four million, the same query takes eleven seconds and the page times out. Nothing changed except the size of the table, and that is the whole story: without help, the database answers WHERE user_id = 42 by reading every single row and checking each one.

That analogy also tells you the cost, which is the half people forget. The index at the back of a book has to be rebuilt every time you edit a page. Indexes are not free, and an index nobody uses is pure overhead. ...

Want to learn PostgreSQL Indexes in a real environment?

Click below, get a fresh Linux box with PostgreSQL ready to go, and work through Indexes hands-on with an AI tutor that knows your code.

Start this lessonIndexes

What you'll learn

  • B-tree default
  • CREATE INDEX
  • Multi-column index
  • Partial index WHERE active
  • Unique index
  • Write cost
  • EXPLAIN preview

Read this lesson in your language

All lessons in this course

14 lessons
  1. 1What is PostgreSQL20 min
  2. 2psql and First Commands25 min
  3. 3Creating Databases and Tables30 min
  4. 4Data Types25 min
  5. 5SELECT and WHERE30 min
  6. 6Joins35 min
  7. 7Aggregates and Grouping30 min
  8. 8Indexes35 min
  9. 9Transactions and Isolation35 min
  10. 10Functions and Triggers35 min
  11. 11JSONB and Arrays35 min
  12. 12EXPLAIN and Query Tuning35 min
  13. 13Backup and Restore25 min
  14. 14Capstone: Design a Schema60 min

Explore other courses

Indexes - PostgreSQL (English) | Engineering Courses