← Salesforce Interview Insights

Salesforce·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026

Summary

Got a deep database theory question at Salesforce for a software engineer role. Not a coding round, just pure concepts, and it went further than I expected.

Questions Asked (3)

Q1

Walk through the four standard transaction isolation levels and explain which anomalies each one prevents.

Technical Trade-offsSystem Design
Author's notes

Started okay, listed them in order and matched dirty reads to Read Uncommitted, non-repeatable reads to Read Committed, and so on.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the four isolation levels in order of increasing strictness (Read Uncommitted, Read Committed, Repeatable Read, Serializable) and then map each to the anomalies it prevents (dirty reads, non-repeatable reads, phantom reads). Use a concrete example like a bank transfer to illustrate how each anomaly manifests and is prevented. Conclude by discussing the trade-off between isolation and performance, and mention that implementations vary (e.g., PostgreSQL uses snapshot isolation for Repeatable Read).

Pro tip: Mention that the SQL standard defines the anomalies each level must prevent, but actual databases may be stricter (e.g., PostgreSQL's Repeatable Read prevents phantoms) or use different mechanisms like MVCC. This shows you understand real-world nuances beyond textbook definitions.

1. Define the anomalies

Briefly explain dirty read, non-repeatable read, and phantom read with simple examples to set the stage.

2. List isolation levels in order

Present the four levels from weakest to strongest: Read Uncommitted, Read Committed, Repeatable Read, Serializable.

3. Map levels to prevented anomalies

For each level, state which anomalies are prevented and which can still occur, using a table-like structure in your explanation.

4. Discuss trade-offs and real-world implementations

Explain that higher isolation reduces concurrency and can cause more blocking or aborts; mention that databases may implement levels differently (e.g., MVCC, snapshot isolation).

5. Conclude with practical implications

Summarize how to choose an isolation level based on application needs, and note that Serializable is often avoided due to performance unless strict consistency is required.

Key Points to Mention

  • Dirty read: reading uncommitted data; prevented by Read Committed and above.
  • Non-repeatable read: same query returns different values within a transaction; prevented by Repeatable Read and above.
  • Phantom read: new rows appear in a repeated query; prevented only by Serializable in the SQL standard.
  • Read Uncommitted allows all three anomalies; Read Committed prevents dirty reads; Repeatable Read prevents dirty and non-repeatable reads; Serializable prevents all three.
  • Trade-off: higher isolation levels reduce concurrency and can lead to more locking, deadlocks, or aborts.
  • Real-world: many databases use MVCC and may not strictly follow the standard (e.g., Oracle doesn't have Read Uncommitted, PostgreSQL's Repeatable Read prevents phantoms).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Compare the locking strategies used by Repeatable Read and Serializable, specifically around lock granularity like row locks, gap locks, and predicate locks.

System DesignTechnical Trade-offsData Modeling
Author's notes

This is where it got uncomfortable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the isolation levels and their goals, then compare lock granularity (row, gap, predicate) and how they prevent phenomena like phantom reads. Use a concrete example (e.g., a range query) to illustrate the differences and trade-offs in concurrency and performance.

Pro tip: Mention that Serializable can be implemented with predicate locks or Serializable Snapshot Isolation (SSI), and that SSI often uses conflict detection instead of locks, which is important for modern databases like PostgreSQL. This shows depth beyond textbook definitions.

1. Define isolation levels and goals

Briefly explain Repeatable Read (RR) and Serializable (SER) in terms of the anomalies they prevent (e.g., phantom reads) and their impact on concurrency.

2. Describe lock granularity in RR

Explain that RR typically uses row locks and gap locks (e.g., in MySQL InnoDB) to prevent phantom reads within a range, but may still allow phantoms in some implementations.

3. Describe lock granularity in SER

Explain that SER uses predicate locks or range locks to ensure full serializability, preventing phantoms by locking all rows matching a predicate, including future inserts.

4. Compare trade-offs

Discuss how SER's finer-grained predicate locks reduce concurrency more than RR's gap locks, but provide stronger guarantees; mention alternative implementations like SSI.

5. Conclude with practical implications

Summarize when to use each level, considering performance and consistency needs, and mention that some databases implement SER without locks using SSI.

Key Points to Mention

  • Repeatable Read prevents non-repeatable reads but may allow phantom reads in some databases (e.g., MySQL InnoDB uses gap locks to prevent phantoms).
  • Serializable prevents all anomalies including phantom reads, often using predicate locks or range locks.
  • Gap locks lock gaps between index records to prevent inserts, while predicate locks lock all rows matching a condition, including future ones.
  • Lock granularity affects concurrency: row locks are finer, gap locks are coarser, predicate locks are logical and can be implemented via SSI.
  • Serializable Snapshot Isolation (SSI) uses conflict detection instead of locks, reducing blocking but may cause more aborts.
  • Trade-off: Serializable provides strongest consistency but lower concurrency; Repeatable Read offers a balance but may require gap locks for phantom prevention.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Explain concretely how the locking differences between Repeatable Read and Serializable actually prevent phantom reads in Serializable but not in Repeatable Read.

System DesignTechnical Trade-offs
Author's notes

Probably the most interesting part of the whole thing.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Define phantom reads and the locking mechanisms of Repeatable Read (RR) and Serializable isolation levels. Explain how RR uses row-level locks that don't prevent new rows, while Serializable adds range locks or predicate locks to block inserts that match the query predicate. Use a concrete example to illustrate the difference.

Pro tip: Mention that many databases implement Serializable using Serializable Snapshot Isolation (SSI) with optimistic conflict detection, not just strict two-phase locking, to show depth and awareness of real-world implementations.

1. Define phantom reads

Explain that a phantom read occurs when a transaction re-executes a query and sees new rows inserted by another committed transaction that match the query's WHERE clause.

2. Describe Repeatable Read locking

Explain that RR typically locks existing rows read by the transaction (e.g., via row-level shared locks or MVCC snapshots) but does not lock the gaps or ranges where new rows could be inserted, so phantoms can occur.

3. Describe Serializable locking

Explain that Serializable adds range locks (or predicate locks) on the index ranges or predicates used in queries, preventing other transactions from inserting rows that would satisfy the predicate, thus eliminating phantoms.

4. Provide a concrete example

Walk through a scenario: Transaction A runs 'SELECT * FROM orders WHERE amount > 100' twice. In RR, Transaction B can insert a new order with amount 150 between the reads, causing a phantom. In Serializable, B's insert is blocked until A commits.

5. Summarize the key difference

Conclude that RR prevents non-repeatable reads but not phantoms because it lacks range locking, while Serializable prevents phantoms by locking the ranges or predicates that define the query's result set.

Key Points to Mention

  • Phantom read definition: new rows appearing in a repeated query
  • Repeatable Read uses row-level locks or MVCC snapshots, not range locks
  • Serializable uses range locks or predicate locks to block inserts
  • Concrete example with a query predicate and concurrent insert
  • Mention that some databases implement Serializable via SSI (optimistic) rather than strict 2PL
  • Note that RR may prevent phantoms in some databases (e.g., MySQL InnoDB with gap locks) but not in the standard definition

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.