Query Optimisation and Pagination Performance
A practical checklist for making a slow query fast, and the specific fix for deep pagination that no amount of indexing solves.
Notes related to SQL.
131 notes tagged
A practical checklist for making a slow query fast, and the specific fix for deep pagination that no amount of indexing solves.
What the engine actually does: full scans versus index seeks, nested loop and hash joins, and why a sort or a temporary table appears in your plan.
What happens between typing a query and getting rows, and how to read an execution plan - the single most useful performance skill in SQL.
Indexes are not free. Learn the cases where the optimiser correctly ignores them, how to find unused and duplicate indexes, and how to maintain them.
Multi column indexes and why their order decides everything: the leftmost prefix rule, selectivity, covering indexes and index only scans.
An index is a sorted lookup structure the database maintains for you. Learn how a B-tree finds a row, what an index costs, and the clustered index in...
Why two transactions can wait for each other forever, how the database resolves it, and the design habits that prevent deadlocks and reduce contention...
How the database stops two transactions corrupting each other: lock modes, granularity, locking reads, and why an unindexed WHERE clause can lock a wh...
The four isolation levels, the three anomalies they prevent, and what each database actually defaults to - with the session by session demonstrations.
Atomicity, consistency, isolation and durability - what each guarantee actually promises, how the database delivers it, and where each one can be weak...
Grouping statements into one unit of work that either fully applies or fully undoes. Learn transaction boundaries, savepoints, autocommit and what sil...
Four ways to name an intermediate result, and a decision rule for choosing between them based on scope, reuse and whether you need an index.