Optimize Performance

When queries slow down, there are three directions to work in: change how the query executes, trade precomputed results for query speed, and allocate resources among concurrent workloads.

If you are not sure where to start, read How Queries Are Processed to see the stages a query goes through, then Automatic Query Optimizations for the optimizations that apply without any change to your SQL.

Change how queries execute

Use GPORCA Optimizer

Choose between the Postgres-based optimizer and GPORCA, each suited to different workloads.

Use GPORCA Optimizer
Update Statistics

Stale statistics skew cost estimates, leading the optimizer to a poor plan.

Update Statistics
Use Query Plan Hints

Specify join order, join method, and scan method when the optimizer’s choice is not right.

Use Query Plan Hints
Optimize HashJoin Query Performance

Large joins hit memory and disk limits while building the hash table; RuntimeFilter filters earlier.

Optimize HashJoin Query Performance
Push Down Aggregation Operations

Move aggregation ahead of the join to reduce the rows that participate.

Push Down Aggregation Operations
Execute Queries in Parallel

Increase the number of compute nodes during execution so one query uses more of the cluster.

Execute Queries in Parallel

Trade precomputation and indexes for speed

Use Automatic Materialized Views

Match existing materialized views during planning, with no SQL rewrite.

Use Automatic Materialized Views
Use Incremental Materialized Views

Refresh only the affected portion when base tables change.

Use Incremental Materialized Views
Use Dynamic Tables

Objects similar to materialized views that refresh on a schedule and can also rewrite queries automatically.

Use Dynamic Tables
Use Index Scan on AO Tables

Use an index instead of a full scan for point lookups on AO tables.

Use Index Scan on AO Tables
Use Unique Indexes on AO Tables

Enforce uniqueness on AO tables at write time.

Use Unique Indexes on AO Tables
Create Indexes Concurrently

Build an index without blocking inserts, updates, and deletes on the table, once the global deadlock detector is enabled.

Create Indexes Concurrently
Create Tables and Refresh Views in Parallel

Use CREATE TABLE AS to build tables in parallel and speed up dependent materialized view refreshes.

Create Tables and Refresh Views in Parallel

Allocate and limit resources

Limit Workloads with Resource Groups

Cap CPU, memory, concurrent transactions, and disk I/O per role so one workload cannot take over the cluster.

Limit Workloads with Resource Groups