Skip to main content

Practice ยท 2 of 2

Pick the index the planner would

Implement best_index(queries, available): - each query is {'filter': [...columns in WHERE order...], 'sort': column-or-None} - an index tuple (a, b, c) covers a query when its leading columns equal the filter columns in order, and its next column equals the sort column (or the query has no sort) - return the index covering the most queries; ties go to the earlier index in available - if any query is covered by NO index, raise ValueError('uncovered query') Column ORDER matters โ€” this is the leftmost-prefix rule as executable code.

Difficulty: advanced

Back to lesson: Practice: Schema & Query Drills