How to Set Up a Staging Environment in Redshift

Galaxy Glossary

How do I create a staging environment in Amazon Redshift?

Creates an isolated Redshift schema or cluster that mirrors production data for safe testing and development.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why create a Redshift staging environment?

Staging lets engineers validate schema changes, run heavy reports, and test ETL without endangering production performance or data integrity.

Which approach fits my workload 7schema or cluster?

Create a separate staging schema inside the same cluster for lightweight testing. Spin up a duplicate cluster when you need full isolation, performance benchmarking, or disaster recovery drills.

How do I create a staging schema quickly?

Run CREATE SCHEMA staging AUTHORIZATION your_user; then duplicate each table with CREATE TABLE staging.table_name (LIKE public.table_name); to copy structure only.

How can I backfill data into staging fast?

Use INSERT INTO staging.table_name SELECT * FROM public.table_name; for small sets. For large volumes, UNLOAD production data to S3 and COPY it into the staging cluster in parallel.

What permissions keep staging safe?

Grant developers SELECT and temporary INSERT on staging tables. Revoke UPDATE/DELETE unless specifically required to avoid accidental data loss.

How do I refresh staging nightly?

Automate a DROP SCHEMA staging CASCADE; followed by a rebuild using the syntax below. Trigger via AWS Scheduler or CI/CD to keep staging in sync with production.

Best practices for staging maintenance?

Tag staging resources, monitor disk usage, and enforce a data-retention policy. Compress unloaded files with gzip to cut S3 costs.

Why How to Set Up a Staging Environment in Redshift is important

How to Set Up a Staging Environment in Redshift Example Usage


--Clone and test a query in staging
WITH repeat_buyers AS (
  SELECT c.id, COUNT(o.id) AS orders_placed
  FROM staging.customers c
  JOIN staging.orders o ON o.customer_id = c.id
  GROUP BY c.id
  HAVING COUNT(o.id) > 3
)
SELECT * FROM repeat_buyers ORDER BY orders_placed DESC;

How to Set Up a Staging Environment in Redshift Syntax


--1. Create staging schema
CREATE SCHEMA staging AUTHORIZATION dev_user;

--2. Clone Customers table structure
CREATE TABLE staging.customers (LIKE public.customers);

--3. Copy data (small tables)
INSERT INTO staging.customers SELECT * FROM public.customers;

--4. Copy large tables via S3
UNLOAD ('SELECT * FROM public.orders')
  TO 's3://my-bucket/orders_' CREDENTIALS 'aws_access_key_id=...;aws_secret_access_key=...'
  GZIP ALLOWOVERWRITE PARALLEL OFF;

CREATE TABLE staging.orders (LIKE public.orders);
COPY staging.orders
  FROM 's3://my-bucket/orders_' CREDENTIALS 'aws_access_key_id=...;aws_secret_access_key=...'
  GZIP CSV;

Common Mistakes

Frequently Asked Questions (FAQs)

Can I snapshot only a few production tables?

Yes. Create those tables in staging with CREATE TABLE ... LIKE and copy data selectively. This speeds up refreshes and saves storage.

Will staging queries slow production?

If you use the same cluster, heavy staging queries can consume resources. Set WLM to give staging a low-priority queue or use a separate cluster.

How often should I refresh staging?

Daily is typical, but high-change apps may need hourly. Balance data freshness with cost and cluster load.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.