db.l3.ai

Play

lessons

what-changed-in-19

editor

engine: not started

results

Run a query to see rows here.

check

Boss: hot and rare keys

hits has 200,000 rows. User 1 owns 90 percent of them and every other user appears once. The prepared statement q(int) is SELECT * FROM hits WHERE user_id = $1 LIMIT 10. A plan built for the hot key is wrong for a rare key, and the other way round.

task

Make both EXECUTE q(1) and EXECUTE q(5000) cheap.

hints