Indexing Strategy and Design Questions
Choosing and designing indexes: B-tree, hash, composite, covering, and partial indexes, and the trade-offs between read acceleration and write/storage overhead. Covers selecting index columns from query patterns, cardinality and selectivity reasoning, and diagnosing why an index is or is not used. Central to database performance interviews.
You are asked to lead a cross-functional project to cut dashboard latency by 50% using indexing, partitioning, and denormalization. Outline a project plan: stakeholders, phases (discovery, prototype, benchmark, rollout), risk assessment, rollback strategy, and key validation steps you would include.
Explain the different index types relevant to analytical systems: B-tree, bitmap, inverted, and zone map indexes. For each index type, describe how it works at a high level, what query patterns it accelerates, and which storage engines (row or columnar) make best use of it.
You have a sales_fact table: (sale_id PK, order_id, product_id, order_date timestamp, amount numeric). Many dashboard queries filter by order_date BETWEEN X AND Y. Write the SQL statement (PostgreSQL) to create a single-column index that speeds date-range filters, and explain any options you would set for a very large table.
Explain the difference between clustered and nonclustered indexes and describe three situations a Business Intelligence Analyst should prefer a clustered index versus a nonclustered index when modeling reporting schemas and OLAP queries. Include implications for storage, range scans, and sort operations.
Define index selectivity and cardinality. Given a customers table with 1,000,000 rows and a column 'country' with 5 unique values and a column 'customer_id' with 1,000,000 unique values, explain which column is a better candidate for an index and why. Also explain how selectivity affects optimizer choice.
Unlock Full Question Bank
Get access to all 46 Indexing Strategy and Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.