AWS Certified DevOps Engineer – ProfessionalResilient Cloud SolutionsMedium

A financial analytics company uses Amazon Redshift as its data warehouse. They frequently load large datasets from Amazon S3 into Redshift tables. During data loading, they need to ensure that the entire batch of data is either completely committed or completely rolled back if any error occurs, maintaining data consistency. Which Redshift command and best practice should they use to achieve this transactional integrity during data loading?

  1. AExecute the `UPDATE` command with a `WHERE` clause to modify existing data based on the new S3 files.
  2. BSplit the large dataset into smaller files and use individual `INSERT` statements for each file.
  3. CUtilize the `COPY` command with `TRANSACTIONAL YES` option to load data from S3.
  4. DUse the `INSERT INTO` command with multiple `VALUES` clauses within a single transaction block.
Show answer & explanation

Correct answer: C. Utilize the `COPY` command with `TRANSACTIONAL YES` option to load data from S3.

The Amazon Redshift `COPY` command is the most efficient way to load large datasets from S3. When using `COPY`, Redshift automatically loads data transactionally. This means that if any part of the load fails, the entire `COPY` operation is rolled back, ensuring atomicity and data consistency. There is no explicit `TRANSACTIONAL YES` option; `COPY` is inherently transactional.

Why the other options are wrong

  • A. `UPDATE` is for modifying existing data, not for loading new large datasets, and doesn't address the transactional integrity of a batch load from S3.
  • B. Individual `INSERT` statements for smaller files would be extremely inefficient for large datasets and would not provide transactional integrity for the entire logical batch.
  • D. `INSERT INTO` is less efficient for large batches and doesn't explicitly guarantee transactional integrity across the entire batch in the same way `COPY` does for S3 loads.

Redshift COPY Command Transactionality

The `COPY` command in Amazon Redshift loads data from S3 into tables as a single, atomic transaction, ensuring that either all data is loaded or none is.

  • Inherently transactional: all-or-nothing operation.
  • Most efficient way to load large datasets from S3.
  • Maintains data consistency during batch loads.

Memory trick: COPY command: Commit completely, consistent forever.

More Resilient Cloud Solutions questions