notesonly.in

One notebook for every subject — open it anywhere.

Log in

Query optimization basics

Database Management Systems · Engineering

Study notes

Query joins 3 tables of 10k, 100k, 1M rows. Bad order: join 100k x 1M first = 10^11 intermediate rows. Good order: filter 10k to 100 rows first, then join: tiny intermediates. The optimizer estimates selectivities from statistics and picks the cheap order; stale statistics cause disasters, so ANALYZE matters.

← Back to topics for Engineering