Practice
1. In a composite index on columns (A, B), a query filters only on column B. At step 3 in the query execution plan, the database engine uses the composite index. What is the state of index usage at this step?
easy
Solution
Step 1: Understand composite index column order
Composite indexes are ordered by the first column (A), then second (B). Queries filtering only on B cannot efficiently seek the index without filtering on A.Step 2: Analyze index usage at step 3
Since column A is not filtered, the engine must scan the entire index or large portions, resulting in a full index scan rather than an efficient seek.Final Answer:
Option A -> Option AQuick Check:
Composite index requires leading column filter for efficient seeks [check]
Hint: Composite index needs leading column filter for seeks [check]
Common Mistakes:
2. In the digital wallet system's transaction processing flow, at Step 4 the Ledger Service applies the debit and credit entries. What happens if the Ledger Service detects a mismatch in the double-entry records at this step?
easy
Solution
Step 1: Understand Ledger Service's double-entry validation
The Ledger Service enforces double-entry consistency; mismatches indicate data corruption or bugs.Step 2: Evaluate failure handling
Retrying indefinitely (A) risks blocking; ignoring mismatch (C) breaks accounting; deleting entries (D) risks data loss. Marking failed and alerting (B) enables safe manual reconciliation.Final Answer:
Option B -> Option BQuick Check:
Mismatch triggers failure mark and alert -> safe reconciliation [check]
Hint: Mismatch triggers failure mark and alert, not silent retry [OK]
Common Mistakes:
3. A distributed system needs to enforce a global rate limit of 1000 requests per second across multiple API servers. Which component is best suited to maintain a consistent count of requests in real-time?
easy
Solution
Step 1: Identify the need for a consistent global count
Local counters aggregated periodically (Use a local in-memory counter on each API server and aggregate periodically) cause stale counts and race conditions, failing real-time enforcement.Step 2: Evaluate Redis atomic increments
Redis supports atomic INCR commands ensuring consistent, real-time global counters across distributed servers.Final Answer:
Option D -> Option DQuick Check:
Redis atomic counters ensure global consistency and low latency [check]
Hint: Centralized atomic counters ensure global consistency [check]
Common Mistakes:
4. You need to design an Elasticsearch cluster optimized for low-latency search queries on a read-heavy workload with occasional node failures. Which architecture choice best balances query speed and fault tolerance?
medium
Solution
Step 1: Evaluate shard size and replication
Multiple smaller shards allow parallel query execution; replicas provide fault tolerance and load balancing.Step 2: Eliminate other options
Single large shard causes query bottleneck; disabling replicas risks data loss and no failover; using only replicas offline is invalid as primaries handle writes.Final Answer:
Option A -> Option AQuick Check:
Multiple shards + replicas balance speed and fault tolerance [check]
Hint: Multiple shards + replicas optimize read speed and fault tolerance [check]
Common Mistakes:
5. For a high-throughput e-commerce platform requiring sortable, unique order IDs generated across multiple regions with minimal coordination, which ID generation approach is best?
medium
Solution
Step 1: Identify requirements
High throughput, sortable, unique IDs across regions with minimal coordination.Step 2: Evaluate options
UUIDv4 (A) is unique but not sortable; centralized auto-increment (C) causes bottlenecks; independent auto-increment (D) risks collisions; Snowflake-style IDs (B) embed timestamp and region, enabling sortable, unique IDs with decentralized generation.Final Answer:
Option A -> Option AQuick Check:
Snowflake IDs -> sortable, unique, decentralized [check]
Hint: Sortable unique IDs at scale -> Snowflake pattern [check]
Common Mistakes:
