A B-tree is sorted by the first column, then the second within it. Values of b are scattered across the whole index, so filtering on b alone cannot seek - the planner ignores the index and scans the table.
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-25