Kacam.net

Observe the world

Databases: one piece at a time

Not sliced as "indexing / transactions / tuning" — an answer key for a topic that broad can only say "watch selectivity, watch locks". These are cut narrow: the column order of a composite index, what one UPDATE actually locks, what OFFSET really does.

These prompts only exist in 简体中文 for now.

How to use this

These are learning drills: the model guides, it does not corner you. When you get stuck it first asks which layer you are stuck at (never heard of it / know it but not why / know why but cannot apply it), then decides what to give. It only explains after guiding twice, and then asks you to say it back in your own words.

It assumes MySQL / InnoDB by default — half the traps here are implementation details, and clustered indexes, back-to-the-table lookups and gap locks work differently elsewhere. PostgreSQL or anything else is fine: say so in your first message and it will follow your engine, calling out where the conclusions differ.

How to start

  1. Pick one, open it, copy the prompt.
  2. Paste it into a fresh, empty chat, and say which engine and version you use first (say nothing and it assumes MySQL 8).
  3. Then say nothing else and wait for its first question.

Four commands you can call out any time

  • 跳过 Move on to the next scene
  • 换个说法 Explain this bit from another angle
  • 直说吧 Give the full answer, then make me say it back
  • 复盘 Jump straight to the wrap-up card

Three traps

  • Do not read the answer key at the end first — the "what people get wrong" section is the answer to every question in the drill.
  • Expect to be pushed for numbers. "A bit faster", "saves IO" gets cut off on the spot: how many rows? how many times? how many times faster? A conclusion with no number behind it is memorised.
  • The moment it starts praising you, point it back at the "do not praise me" rule. Guiding is not coddling.

Start with the composite index one — it is the foundation here; "locks sit on index records" and "why is it scanning so many rows" both lean on its one-line model. If concurrency is biting you in production, start with read-modify-write instead; if queries are slow, start with the execution plan one.

Indexes

一次查询读了几棵树
一次查询到底读了几棵树、回表几次?
★★★☆☆ · about 30 min
These prompts are open source They live in the public kacam-net/hero-prompts repo. If one of them doesn't press hard enough, or its answer key is missing a line, go and change it — whether it ships here is a separate call, made by the catalogue on this side.