2025-01-04
Main point: reading is faster, writing is slower, compound indexes are a thing.
Main point: get everyone to a point where they are confident to actively participate in a group discussion on indices.
In triples or pairs, depending on how large a fraction of the audience considers themselves comfortable with indexes (triples if few, pairs if many, or maybe just triples regardless). Participants should have access to an instance of MongoDB or PostgreSQL filled with example data (maybe both?). The idea is to have a bunch of questions on the theory of indices, the answers to which the participants can verify using the example database.
Main point: apply the theory to your own applications.
Probably in two or three groups, depending on the number of participants. Maybe one group per team. Idea is to discuss what's been learned in light of queries in the particpants' own codebases. Should be very loose, but with some leading questions to get the conversation started.
Main point: spread the insights gained from the group discussion.
Back to one single group, and participants from the groups from the previous section share (if they want) what they learned.
WHERESELECT * FROM table WHERE a=3
filler
SELECT * FROM table WHERE 1 <= unindexed_column < 3
filler
SELECT * FROM table ORDER BY indexed_column
filler
SELECT a FROM table WHERE a=3;
Run
SELECT * FROM table WHERE a=3 AND b=5;
with no index, index on a and b separately, (a, b), one on (b, c), and one on (a, b, c), and one on (c, a, b).
SELECT * FROM table WHERE a < 3;
filler
SELECT * FROM table WHERE a < 3 AND b > 1;
filler
SELECT * FROM table WHERE a = 3 ORDER BY b;
filler
SELECT * FROM table ORDER BY a
Sort order of indexes