P-6.5 Indexes, Transactions and Failing Safely
You can read a query plan, decide where an index earns its cost, and explain what a transaction guarantees when something fails halfway through.
Two mechanisms account for most of the difference between a database that copes and one that does not. An index makes reads fast and writes slower, and the only honest way to decide about one is to read the query plan before and after. A transaction makes a group of changes all-or-nothing, which is what stops a failed transfer from taking money out of one account without putting it in the other.
Work through these
What an index is, and why it is a sorted structure beside the table
An index is a separate ordered structure over one or more columns, usually a tree, that lets the database find rows without scanning. It is the same search tree from the earlier module.
Reading a query plan before deciding anything
The database will tell you how it intends to answer a query and what it expects that to cost. Adding indexes without reading this is guessing at a problem the system can describe precisely.
PostgreSQL Documentation: Tutorial · DocsEvery index makes writes slower and takes space
An index must be updated on every insert, update and delete that touches its columns. Indexing everything is a way of making a database slower while feeling productive.
Transactions: all of it happens or none of it does
Grouping statements means a failure partway through leaves the data as it was rather than half changed. This is the guarantee that makes money transfers and stock adjustments safe to write.
NPTEL: Data Base Management System · CourseConcurrent access, and what isolation levels trade away
Several sessions changing the same rows need rules about what each can see, and stricter rules cost throughput. Knowing your database's default is the practical half of this.
Sign in to keep your progress.
Free resources
Links last checked 31 Aug 2026.
Stuck here?
Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.
Checking your session…
Topics shown in module order.