Viewed
NEW
Explanation
Google
Gemini 2.5 Flash-Lite
VS
OpenAI
GPT-5.2
Explain Database Indexing to a Junior Developer
You are a senior software engineer mentoring a junior developer who has been writing SQL queries for about six months but has never created or thought about database indexes. They have just complained that their queries on a table with 10 million rows are running very slowly.
Write a clear, structured explanation of database indexing for this audience. Your explanation should cover:
1. What a database index is and why it exists, using at least one concrete analogy that a beginner would find intuitive.
2. How a basic B-tree index works at a conceptual level (no need for full algorithmic detail, but enough that the reader understands why lookups become faster).
3. The trade-offs of indexing — when indexes help, when they hurt, and what costs they introduce.
4. Practical guidance on how to decide which columns to index, including at least two realistic examples of queries and whether/how they would benefit from an index.
5. A brief note on composite (multi-column) indexes and why column order matters.
Aim for an explanation that is thorough yet accessible — avoid unnecessary jargon, but do not oversimplify to the point of inaccuracy. The reader should finish your explanation feeling confident enough to create their first index and reason about whether it will help.