During a nightly table swap in Amazon Redshift, other sessions must not read or write the table until the swap completes. What can you use?
- Exam domain
- Data Store Management26% of the exam
- Difficulty
- Hard
- In this mock
- 23 questions on this domainPractise this domain
Why the exam asks this
Task Statement 2.1: Choose a data store.
Objective in the exam guide: Manage locks to prevent access to data (for example, Amazon Redshift, Amazon RDS).
Concurrent jobs can read half-finished data or overwrite each other. Locks are how databases keep critical operations consistent.
Why D is the answer
The LOCK command to restrict access to the table during the operation
LOCK restricts access to a table so a critical operation completes without interference.
Remember: Prevent access during a critical operation: lock the table, briefly.
How it works
A lock controls which sessions can access a table while an operation runs.
In Redshift, the LOCK command restricts access to a table, so other sessions wait until the transaction ends.
Locks protect consistency but make others wait, so locked windows should be short.
Clues in the question
The words that point to the answer, and what each one tells you.
- Must not read or write the table until the swap completes
- Exclusive access: a lock.
In detail
- Explicit locks can cause other sessions to wait, so keep the locked window short.
- Relational databases such as RDS also use locks to protect concurrent changes.
Side by side with look-alikes
| Option | Blocks access during the swap? |
|---|---|
| LOCK | Yes |
| Larger cluster | No |
| Distribution key | No |
| Materialized view | No |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. A larger clusterWrong
Cluster size does not control concurrent access.
B. A new distribution keyWrong
Distribution affects performance, not access.
C. A materialized viewWrongMost tempting
A materialized view is a precomputed result, not a lock.
Why it tempts: Views can present a stable result to readers. But they do not stop sessions from accessing the table being swapped.
D. The LOCK command to restrict access to the table during the operationRight
Prevent access during a critical operation: lock the table, briefly.
In practice
- Run the lock and swap in one short transaction.
Use case
An illustrative scenario, not a real incident.
A team locks the staging table during its rename swap, which completes in seconds without readers seeing partial data.
See how it works
sequenceDiagram participant J as Swap job participant T as Table participant R as Reader session J->>T: LOCK and start swap R->>T: SELECT T-->>R: Waits for the lock J->>T: Commit swap T-->>R: Reads the new table
How to read this chart
- 1. Swap job sends "LOCK and start swap" to Table.
- 2. Reader session sends "SELECT" to Table.
- 3. Reader session gets a reply from Table: "Waits for the lock".
- 4. Swap job sends "Commit swap" to Table.
- 5. Reader session gets a reply from Table: "Reads the new table".