Orivel Orivel
Open menu

Teaching Database Indexes to a Junior Backend Developer

Compare model answers for this Explanation benchmark and review scores, judging comments, and related examples.

Login or register to use likes and favorites. Register

X f L

Contents

Task Overview

Benchmark Genres

Explanation

Task Creator Model

Answering Models

Judge Models

Task Prompt

Write a teaching-oriented explanation for a junior backend developer who knows basic SQL SELECT, WHERE, and JOIN syntax but has never intentionally designed database indexes. Explain what a database index is, how it can speed up reads, why it can slow down writes and use extra storage, and how a common B-tree index is used at a high level. Include a practical explanation of selectivity, composite indexes, the leftmost-prefix idea, and situations where an index may not help. Use one simple analogy, but also explain...

Show more

Write a teaching-oriented explanation for a junior backend developer who knows basic SQL SELECT, WHERE, and JOIN syntax but has never intentionally designed database indexes. Explain what a database index is, how it can speed up reads, why it can slow down writes and use extra storage, and how a common B-tree index is used at a high level. Include a practical explanation of selectivity, composite indexes, the leftmost-prefix idea, and situations where an index may not help. Use one simple analogy, but also explain the real database behavior directly. Include two small SQL examples showing a useful index choice and a less useful or problematic index choice. End with a short practical checklist the developer could use when deciding whether to add an index.

Task Context

Assume a generic relational database such as PostgreSQL, MySQL, or SQLite. Avoid relying on vendor-specific syntax or advanced database internals beyond what is needed for practical understanding.

Judging Policy

A strong answer should be accurate, clear, and well matched to a junior backend developer. It should explain indexes as separate data structures that help the database find rows without scanning everything, describe read and write tradeoffs, and correctly cover B-tree behavior at a high level without overcomplicating it. It should make selectivity, composite indexes, and the leftmost-prefix idea understandable through practical examples. The SQL examples should be small, coherent, and relevant, and the answer shoul...

Show more

A strong answer should be accurate, clear, and well matched to a junior backend developer. It should explain indexes as separate data structures that help the database find rows without scanning everything, describe read and write tradeoffs, and correctly cover B-tree behavior at a high level without overcomplicating it. It should make selectivity, composite indexes, and the leftmost-prefix idea understandable through practical examples. The SQL examples should be small, coherent, and relevant, and the answer should avoid misleading rules such as always indexing every column or assuming an index is always used. The final checklist should be actionable and should connect indexing decisions to real query patterns, data distribution, and maintenance costs.

Answers

Understanding Database Indexes: A Practical Guide

What an index is

A database index is a separate data structure the database maintains alongside a table. It stores the values of one or more columns in a sorted, searchable form, together with pointers back to the actual rows. The table itself stores your data; the index is an extra structure whose only job is to help the database find rows faster.

Here is one analogy, and it is the only one you need: an index is like the index at the back of a textbook. If you want every page that mentions "transactions," you do not read the whole book page by page; you look u...

Show Full Answer

Understanding Database Indexes: A Practical Guide

What an index is

A database index is a separate data structure the database maintains alongside a table. It stores the values of one or more columns in a sorted, searchable form, together with pointers back to the actual rows. The table itself stores your data; the index is an extra structure whose only job is to help the database find rows faster.

Here is one analogy, and it is the only one you need: an index is like the index at the back of a textbook. If you want every page that mentions "transactions," you do not read the whole book page by page; you look up "transactions" in the alphabetically sorted index, get a short list of page numbers, and jump straight to them. Without that index, your only option is to scan every page. A database faces exactly the same choice: use an index to jump to matching rows, or scan the whole table.

Now the real behavior, without the analogy. When you run a query like SELECT * FROM orders WHERE customer_id = 42, the database has two basic strategies. A full table scan reads every row and checks the condition, which costs time proportional to the size of the table. An index lookup instead searches the sorted index structure for customer_id = 42, finds the matching entries quickly, and follows the stored pointers to fetch just those rows. For a large table where only a few rows match, the index path can be thousands of times cheaper.

How a B-tree index works, at a high level

The most common index type is a B-tree. It is a balanced tree structure where keys are kept in sorted order. The top node divides the key space into ranges, each child node subdivides further, and the bottom level (the leaves) contains the actual indexed values with pointers to the table rows. Because the tree is balanced and each node holds many keys, even a table with hundreds of millions of rows usually needs only three to five node reads to find any specific value.

Because a B-tree keeps values in sorted order, it supports more than exact matches. It efficiently handles range conditions (WHERE created_at >= '2024-01-01'), prefix matches on strings (WHERE email LIKE 'anna%'), and can return rows already sorted, which lets the database skip a separate sort step for matching ORDER BY clauses.

Why indexes cost something

Indexes are not free, and this is the trade-off you must internalize.

Writes get slower. Every INSERT must add an entry to every index on the table. Every DELETE must remove entries. Every UPDATE that changes an indexed column must update the corresponding index entries. A table with six indexes effectively does up to seven writes for every logical row insert. On write-heavy tables, careless indexing measurably hurts throughput.

Storage grows. Each index is a full copy of the indexed column values plus pointers and tree structure. Indexes on large tables can rival or exceed the size of the table itself, which also affects backups and memory caching.

So the guiding principle is: indexes trade write cost and storage for read speed. You add them where reads benefit clearly, not everywhere.

Selectivity: the key concept for deciding value

Selectivity describes how well a condition narrows down rows. A highly selective column has many distinct values relative to the row count. An email or order ID is highly selective: filtering on it returns one or a handful of rows out of millions, and an index shines. A column like status with three values ('pending', 'shipped', 'cancelled') or a boolean is_active flag has low selectivity: filtering may still match 40% of the table.

Why does this matter? If a condition matches a large fraction of the table, jumping back and forth between the index and the table for millions of rows is often slower than just scanning the table sequentially. Query planners know this and will ignore an index when the estimated match fraction is too high. As a rough intuition, if a typical query using the index would return more than a few percent of the rows, the index may not be used at all, and it is pure overhead.

Composite indexes and the leftmost-prefix rule

An index can cover multiple columns, in a specific order. For example:

CREATE INDEX idx_orders_customer_date ON orders (customer_id, created_at);

Think of this as sorting entries first by customer_id, then by created_at within each customer, like a phone book sorted by last name, then first name.

The leftmost-prefix idea follows directly from that sort order. This index can efficiently serve:

  • WHERE customer_id = 42
  • WHERE customer_id = 42 AND created_at >= '2024-01-01'

But it cannot efficiently serve WHERE created_at >= '2024-01-01' alone, because entries for a given date range are scattered across all customers; you cannot use a phone book sorted by last name to find everyone named "Anna." The index is usable only when your conditions constrain a prefix of its column list, starting from the leftmost column. This means (customer_id, created_at) and (created_at, customer_id) are different indexes serving different queries, and column order should follow your most important query patterns. A common rule of thumb: put equality-filtered columns first, then the range or sort column.

When an index does not help

  • Low selectivity: filtering WHERE is_active = true on a table where 90% of rows are active. The planner will scan instead.
  • Functions or expressions on the column: WHERE LOWER(email) = 'x@y.com' cannot use a plain index on email, because the index stores raw values, not transformed ones. (Some databases support expression indexes, but the plain index will not be used.)
  • Leading wildcards: WHERE name LIKE '%son' cannot use a B-tree, because the sorted order helps only when the prefix is known.
  • Skipping the leftmost column of a composite index, as described above.
  • Tiny tables: for a few hundred rows, a scan is already fast; the index adds write cost for no benefit.
  • Type mismatches or implicit casts on the indexed column can also prevent index use.

Two small examples

A useful index. Suppose your application constantly runs:

SELECT id, total, created_at
FROM orders
WHERE customer_id = 42
ORDER BY created_at DESC
LIMIT 20;

Then this index fits perfectly:

CREATE INDEX idx_orders_customer_date ON orders (customer_id, created_at);

The database jumps to customer 42's entries, which are already sorted by created_at, reads the newest 20, and stops. It is fast on a table of any size, and it also serves plain lookups by customer_id thanks to the leftmost prefix.

A problematic index. Suppose you instead create:

CREATE INDEX idx_orders_status ON orders (status);

where status has three possible values and most rows are 'shipped'. A query like SELECT * FROM orders WHERE status = 'shipped' matches most of the table, so the planner will do a table scan anyway. The index is rarely or never used, yet every insert and every status update pays to maintain it. This is a net loss. (An exception worth knowing: indexing a low-cardinality column can pay off when one value is rare and heavily queried, such as the small set of 'pending' orders, but the generic version above is a classic mistake.)

Practical checklist before adding an index

  1. Identify the actual slow query first; do not index speculatively. Look at real query patterns and use EXPLAIN to see the current plan.
  2. Check selectivity: will typical queries using this index return a small fraction of the table? If not, reconsider.
  3. For multi-column filters and sorts, design one composite index with the right column order (equality columns first, then range/sort columns) rather than several single-column indexes.
  4. Confirm the leftmost-prefix rule: does your most common query constrain the first column of the index?
  5. Make sure the query does not defeat the index with functions, leading wildcards, or type casts on the indexed column.
  6. Weigh write traffic: on heavily written tables, every extra index has a real cost. Remove indexes that overlap with or are prefixes of others.
  7. Check whether an existing index already covers the query before creating a new one.
  8. After creating the index, verify with EXPLAIN that the planner actually uses it, and measure the query time before and after.
  9. Periodically review and drop unused indexes; they cost writes and storage forever.

The core mental model to keep: an index is a sorted lookup structure you pay for on every write so that specific, selective reads become cheap. Add one when you can name the query it serves and show that it helps.

Result

#1 | Winner

Winning Votes

3 / 3

Average Score

90

Total Score

89

Overall Comments

Answer A is thorough, accurate, and exceptionally well-matched to the target audience. It cleanly separates the analogy from the real database behavior (as the prompt explicitly requested), explains B-tree structure with concrete detail about node reads, and covers write costs, storage, and selectivity with correct nuance including the case where indexing a rare low-cardinality value can still pay off. It fully addresses composite indexes and the leftmost-prefix rule with a strong phone-book illustration, and includes a rich "when an index does not help" section (functions, leading wildcards, type casts, tiny tables). The two SQL examples are coherent and directly tied to query patterns, and the checklist is highly actionable, referencing EXPLAIN, measurement, and dropping unused indexes. Minor weakness: it is longer and denser than strictly necessary, but this rarely harms comprehension given the strong structure.

View Score Details

Clarity

Weight 30%
90

Explanations are precise and build logically; the deliberate separation of analogy from real behavior, the phone-book illustration for column order, and the closing mental model make abstract concepts vivid. Slightly denser than B but never confusing.

Correctness

Weight 25%
90

Technically accurate throughout, including subtle points: planners ignoring low-selectivity indexes, expression indexes as an exception, leading-wildcard failure, type-cast issues, and the correct note that a rare heavily-queried low-cardinality value can still benefit. B-tree node-read estimate is reasonable.

Audience Fit

Weight 20%
90

Well-tuned to a junior developer who knows SELECT/WHERE/JOIN: it avoids deep internals, names the practical rules of thumb, and ties every concept to a decision the developer can make. Density is the only minor risk for a novice.

Completeness

Weight 15%
90

Covers every requested element and more: index-as-structure, read speedup, write/storage cost, high-level B-tree, selectivity, composite indexes, leftmost prefix, multiple non-helping cases, two contrasting SQL examples, and a rich checklist including EXPLAIN and dropping unused indexes.

Structure

Weight 10%
80

Logical, well-sectioned flow from definition through tradeoffs, selectivity, composite indexes, non-helping cases, examples, and checklist. Slightly heavier text blocks reduce scannability compared with B.

Total Score

92

Overall Comments

Answer A provides an exceptionally clear, comprehensive, and practical explanation of database indexes tailored perfectly for a junior backend developer. It covers all required topics with excellent depth, including a robust section on situations where indexes don't help and a highly actionable checklist. The analogies and direct explanations are well-integrated, and the SQL examples are pertinent.

View Score Details

Clarity

Weight 30%
90

Answer A is exceptionally clear, using well-structured headings, precise language, and effective analogies (like the phone book for leftmost-prefix) to explain complex concepts. The flow is logical and easy to follow.

Correctness

Weight 25%
95

Answer A is highly accurate across all explanations, from the B-tree mechanics to the nuances of selectivity and composite indexes. It correctly identifies various scenarios where indexes are beneficial or detrimental, including supporting range queries and ORDER BY clauses with B-trees.

Audience Fit

Weight 20%
90

Answer A is perfectly tailored for a junior backend developer. The language is accessible, the analogy is simple and effective, and the practical advice is comprehensive without being overwhelming. The 'core mental model' at the end is a great summary for the target audience.

Completeness

Weight 15%
95

Answer A is highly complete, covering all requested topics in depth. It provides a very comprehensive list of situations where an index may not help and a detailed, actionable checklist, exceeding expectations for practical guidance.

Structure

Weight 10%
90

Answer A has an excellent structure with clear, descriptive headings that guide the reader through the material logically. Each concept is introduced and explained in a well-organized manner, making the content easy to digest.

Judge Models OpenAI GPT-5.5

Total Score

89

Overall Comments

Answer A is a highly complete, accurate, and well-structured teaching explanation. It clearly explains indexes as separate sorted lookup structures, covers B-tree behavior, read/write/storage tradeoffs, selectivity, composite indexes, leftmost-prefix behavior, and many situations where indexes may not help. Its examples are practical and its final checklist is directly actionable. Minor weaknesses are a few broad simplifications, such as implying certain B-tree LIKE-prefix behavior generically and saying the example index is fast on a table of any size, but these do not materially harm the explanation.

View Score Details

Clarity

Weight 30%
88

Answer A is very clear, with direct explanations, concrete examples, and smooth transitions from analogy to real database behavior. It is somewhat long, but the detail generally improves understanding rather than obscuring it.

Correctness

Weight 25%
90

Answer A is technically accurate for a generic relational database at the intended level. It correctly explains separate index structures, B-tree lookup, read/write/storage tradeoffs, selectivity, composite index ordering, and common non-use cases, with only minor generic simplifications.

Audience Fit

Weight 20%
87

Answer A is well matched to a junior backend developer who knows basic SQL. It gives practical mental models, realistic examples, and actionable guidance, though its breadth may be slightly dense for a first introduction.

Completeness

Weight 15%
93

Answer A covers nearly every requested element: what indexes are, read speedups, write and storage costs, B-tree behavior, selectivity, composite indexes, leftmost-prefix behavior, multiple cases where indexes may not help, two SQL examples, and a strong checklist.

Structure

Weight 10%
90

Answer A is very well organized, with clear headings, logical progression, examples placed after concepts, and a practical checklist at the end. The structure strongly supports learning.

Let's talk about database indexes. You've been writing SQL queries, and they probably work great on your development machine with a few hundred rows. But when a table grows to millions of rows, some of those queries can become incredibly slow. An index is the most common tool we use to solve this problem.

What is a Database Index? An Analogy

Think of an index like the index at the back of a textbook. If you want to find every page that mentions "B-trees," you don't read the entire book from cover to cover. Instead, you go to the index, find the entry for "B-trees," and see a sorted list of page numbers (e.g...

Show Full Answer

Let's talk about database indexes. You've been writing SQL queries, and they probably work great on your development machine with a few hundred rows. But when a table grows to millions of rows, some of those queries can become incredibly slow. An index is the most common tool we use to solve this problem.

What is a Database Index? An Analogy

Think of an index like the index at the back of a textbook. If you want to find every page that mentions "B-trees," you don't read the entire book from cover to cover. Instead, you go to the index, find the entry for "B-trees," and see a sorted list of page numbers (e.g., 112, 254, 256). This is much faster.

A database index works the same way. It's a separate data structure that the database maintains. It holds a copy of the data from one or more columns in a sorted order, along with a pointer back to the original row in the table. When you query for data in that column, the database can use this sorted index to quickly find the pointers to the rows you need, instead of scanning the entire table one row at a time (a "full table scan").

How It Works: The B-Tree

Most relational databases use a B-tree for their standard indexes. You don't need to know the deep computer science details, but at a high level, a B-tree is a self-balancing tree structure. Imagine a branching hierarchy. To find a value, the database starts at the root node and follows a path down the branches. Each step dramatically narrows down the search. This allows the database to find any value in a massive dataset with very few steps, making searches incredibly efficient (logarithmic time complexity, or O(log n)) compared to a full table scan (linear time complexity, or O(n)).

The Trade-offs: Write Speed and Storage

Indexes are not free. They come with two main costs:

  1. Storage: An index is a physical data structure stored on disk. It duplicates data from your table, so it consumes extra storage space.
  2. Slower Writes: This is the most important trade-off. When you INSERT, UPDATE, or DELETE a row, the database doesn't just change the table. It must also update every single index that contains the affected columns to keep it in sync and sorted. If you have a table with five indexes, one INSERT statement actually results in six writes: one for the table and one for each index. This can significantly slow down write-heavy applications.

Key Concepts for Practical Indexing

1. Selectivity
Selectivity refers to how many unique values are in a column relative to the total number of rows.

  • High Selectivity: A column where most values are unique, like user_id or email_address. Indexes on these columns are very effective because they can narrow a search down to just one or a few rows very quickly.
  • Low Selectivity: A column with very few unique values, like a boolean is_active flag (true/false) or a status column ('pending', 'active', 'inactive'). An index on a low-selectivity column is often useless. If you search for all active users, that might be 80% of your table. It's faster for the database to just read the whole table than to jump back and forth between an index and the table data.

2. Composite Indexes and the Leftmost-Prefix Rule
A composite index is an index on two or more columns, like CREATE INDEX idx_name ON users (last_name, first_name);.

The order of columns is critical. This is the leftmost-prefix rule. An index on (A, B, C) can be used by the database to speed up queries that filter on:

  • A
  • A and B
  • A, B, and C

However, it cannot be used for queries that only filter on B, C, or B and C. The database needs the first column(s) in the index definition to start its search.

SQL Examples

Let's assume a products table with millions of rows.

Good Index Example:
Many users are searching for products by a unique product code.

-- The Query
SELECT name, price FROM products WHERE product_code = 'ABC-12345';

-- The Solution: An index on a high-selectivity column
CREATE INDEX idx_products_product_code ON products (product_code);

This index is highly effective because product_code is unique (high selectivity), and the index allows the database to find the exact product row almost instantly.

Less Useful Index Example:
We want to find all products that are currently available for sale.

-- The Query
SELECT * FROM products WHERE is_available = TRUE;

-- The Problematic Index
CREATE INDEX idx_products_is_available ON products (is_available);

This index is not very useful. The is_available column has low selectivity (only two values: true and false). If 90% of products are available, the database will likely ignore this index and perform a full table scan, as it's more efficient.

Checklist: When to Add an Index

Before adding an index, ask yourself these questions:

  1. Is the table large? (Indexes on small tables have little to no benefit).
  2. Is a specific query running slowly? (Don't add indexes blindly; add them to fix a known performance problem).
  3. Am I filtering on this column frequently in a WHERE clause or using it in a JOIN? (These are the primary candidates for indexing).
  4. Does the column have high selectivity? (Will the index significantly narrow down the number of rows to check?).
  5. For a composite index, does my query use the leftmost column(s) of the index?
  6. Is this a read-heavy table? (If the table has very frequent writes but few reads, the cost of maintaining the index might outweigh the read benefits).

Result

#2

Winning Votes

0 / 3

Average Score

81

Total Score

78

Overall Comments

Answer B is clear, well-organized, and appropriately pitched for a junior developer. It uses the textbook analogy, explains B-tree behavior at a high level with Big-O notation, and covers the read/write/storage tradeoffs accurately. Selectivity, composite indexes, and the leftmost-prefix rule are explained correctly and concisely. The two SQL examples are clean and relevant. However, it is noticeably less complete: the "when an index may not help" requirement is only partially covered (mainly low selectivity), missing functions/expressions, leading wildcards, type casts, and the skipped-leftmost-column case. It also does not clearly separate the analogy from direct database behavior as explicitly requested, and the checklist, while solid, is less actionable (no mention of EXPLAIN, measurement, or maintenance/dropping unused indexes).

View Score Details

Clarity

Weight 30%
80

Very readable and clean with good headings and simple phrasing. The Big-O framing is a nice touch. Slightly less illustrative on composite index ordering (no concrete sort-order intuition), and the analogy and real behavior are somewhat blended rather than clearly distinguished.

Correctness

Weight 25%
80

Accurate on all core points: B-tree logarithmic search, write amplification math, selectivity, and leftmost-prefix. No errors, but it omits several correct caveats (functions, wildcards, casts) and gives a slightly less complete picture of when indexes fail.

Audience Fit

Weight 20%
80

Excellent fit: friendly tone, opens by relating to the reader's own experience of slow queries at scale, and keeps jargon minimal with brief Big-O explanation. Very approachable, though slightly less depth for a developer wanting to act on edge cases.

Completeness

Weight 15%
60

Covers most required elements but is thinner on 'situations where an index may not help,' effectively limiting it to low selectivity while omitting functions/expressions, leading wildcards, casts, and skipped-prefix cases. It also does not explicitly contrast the analogy with direct behavior as requested.

Structure

Weight 10%
90

Clean, scannable structure with clear headings, numbered lists, and well-formatted code blocks. The organization is tight and easy to navigate, marginally better presented than A.

Total Score

85

Overall Comments

Answer B offers a very good explanation of database indexes, with a strong introduction and clear, concise explanations of core concepts. It uses a good analogy and provides relevant SQL examples. However, it is less comprehensive than Answer A, particularly in its coverage of situations where an index may not help and its final checklist is less detailed.

View Score Details

Clarity

Weight 30%
85

Answer B is very clear and concise, with good use of headings and bullet points. The explanations are generally easy to understand, though the mention of 'logarithmic time complexity' might be slightly advanced for a junior developer, even with a quick explanation.

Correctness

Weight 25%
90

Answer B is correct in all its explanations of core concepts. The B-tree description, trade-offs, selectivity, and leftmost-prefix rule are all accurately presented. No factual errors were identified.

Audience Fit

Weight 20%
88

Answer B is also well-suited for the target audience, with a relatable introduction and straightforward explanations. The language is simple and direct, making it easy for a junior developer to grasp the concepts.

Completeness

Weight 15%
75

Answer B covers most of the requested topics but is less complete than Answer A. Its section on 'situations where an index may not help' is less exhaustive, missing key points like functions on columns or leading wildcards. The final checklist is also shorter and less detailed.

Structure

Weight 10%
85

Answer B is well-structured with clear headings and effective use of bullet points. The information flows logically, making it easy to read and understand the different sections.

Judge Models OpenAI GPT-5.5

Total Score

79

Overall Comments

Answer B is clear, approachable, and mostly correct for a junior developer. It explains the core concept, the textbook analogy, B-tree search at a high level, write/storage costs, selectivity, composite indexes, and leftmost-prefix behavior. However, it is less complete than Answer A: it gives fewer cases where indexes may not help, does not discuss functions, leading wildcards, range/order behavior, planner choices in much depth, or how to verify with EXPLAIN, and its checklist is more basic.

View Score Details

Clarity

Weight 30%
81

Answer B is clear and easy to follow, using simple language and concise sections. It is slightly less explanatory in some areas, especially around planner decisions and when indexes are ignored.

Correctness

Weight 25%
80

Answer B is mostly correct and avoids major misleading claims. Its explanations of B-trees, selectivity, and composite indexes are sound, but it is more simplified and omits some important caveats about index usability and database planner behavior.

Audience Fit

Weight 20%
84

Answer B is very accessible for a junior developer, with friendly language and straightforward examples. It is less deep than ideal for someone starting to intentionally design indexes, but the tone and complexity level are appropriate.

Completeness

Weight 15%
68

Answer B covers the main concepts and includes two SQL examples and a checklist, but it misses several requested or important practical points, such as functions on indexed columns, leading wildcards, type casts, range and ORDER BY usefulness, and verification with execution plans.

Structure

Weight 10%
80

Answer B has a clean and readable structure with headings, bullet points, examples, and a checklist. It is coherent, though less comprehensive and less tightly connected to real query-design decisions than Answer A.

Comparison Summary

Final rank order is determined by judge-wise rank aggregation (average rank + Borda tie-break). Average score is shown for reference.

Judges: 3

Winning Votes

3 / 3

Average Score

90
View this answer

Winning Votes

0 / 3

Average Score

81
View this answer

Judging Results

Judge Models OpenAI GPT-5.5

Why This Side Won

Answer A wins because it is stronger on the heavily weighted criteria of clarity and correctness while also being substantially more complete. It covers all requested topics in practical depth, includes better discussion of edge cases where indexes may not help, gives more relevant composite-index guidance, and ends with a more actionable checklist. Answer B is good, but it omits several important practical considerations required by the prompt.

Why This Side Won

Answer A wins due to its superior completeness and depth, especially in practical advice crucial for a junior developer. Its section on 'When an index does not help' is far more comprehensive, covering important edge cases like functions on columns, leading wildcards, and type mismatches. Additionally, its practical checklist is more detailed and actionable, providing a better guide for real-world decision-making. While both answers are clear and correct, Answer A's thoroughness makes it a more valuable teaching resource.

Why This Side Won

Answer A wins on the two most heavily weighted criteria, clarity (30%) and correctness (25%), while also decisively winning completeness (15%). It explicitly fulfills nuanced prompt requirements that B omits or only partially addresses: separating the analogy from direct database behavior, a full "when an index does not help" section (functions, wildcards, casts, tiny tables, skipped prefix), the equality-then-range column ordering rule, and an actionable checklist referencing EXPLAIN and index maintenance. B is clean and correct but less complete and does not separate analogy from real behavior as requested. The weighted result favors A.

X f L