> ## Documentation Index
> Fetch the complete documentation index at: https://learn.kubit.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Amazon Redshift

> Grant Kubit's VPCs access to your Redshift cluster and create a read-only user so Kubit queries your data in place.

Kubit connects directly to Amazon Redshift and queries your data in place. You grant Kubit's VPCs access to your cluster, create a read-only user and grant it `SELECT` on the data Kubit should see. Nothing is copied out of your account.

## Before you start

* [ ] Admin access to the Redshift cluster or Serverless workgroup, and to its AWS account
* [ ] The AWS region of the cluster
* [ ] The schema, tables or views Kubit should query

## Steps

### 1. Grant access to Kubit's VPCs

Send the AWS region of your Redshift cluster to the Kubit team. Kubit replies with its AWS account ID and VPC IDs.

Then follow AWS's "Granting access to a VPC" guide for Redshift to allow access from those VPCs.

### 2. Create a user

In the database you share with Kubit, create a user for Kubit. The password has to meet Redshift's password rules.

```sql theme={null}
CREATE USER kubit WITH PASSWORD '<password>';
```

### 3. Grant read access

Let the `kubit` user read your analytical data. Either grant access to every table in a schema:

```sql theme={null}
GRANT USAGE ON SCHEMA public TO kubit;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO kubit;
```

Or limit it to specific tables or views:

```sql theme={null}
GRANT USAGE ON SCHEMA public TO kubit;
GRANT SELECT ON TABLE public.table_1 TO kubit;
GRANT SELECT ON TABLE public.table_2 TO kubit;
```

Replace `public`, `table_1` and `table_2` with your own names.

### 4. Add the connection in Kubit

## Verify

Check the grants as an admin. The output has one row per table with `select` set to `true`.

```sql theme={null}
SELECT schemaname, tablename,
       has_table_privilege('kubit', schemaname || '.' || tablename, 'select') AS "select"
FROM pg_tables
WHERE schemaname = 'public';
```

## Best practices

### Cluster type

Kubit recommends Amazon Redshift Serverless. Analytical queries come in at unpredictable times, and Serverless bills per use (RPU hours).

| Type | Fits |
| - | - |
| **Serverless** | Unpredictable, intermittent or ad hoc queries, billed per RPU hour |
| **Provisioned** | Steady, high-throughput, predictable workloads, where reserved capacity costs less over time |

### Sort and distribution keys

Kubit queries time series event data. For fact tables, use these sort keys:

* An event date column
* Event name, since it's the most common filter

In a dimensional model, also choose distribution keys and styles. A fact table has only one distribution key but joins many dimension tables. AWS's "Choose the best sort key" and "Choose the best distribution style" guides cover both.

## Next steps

* [Bring your own warehouse](https://learn.kubit.ai/warehouses/overview.md): how Kubit queries your warehouse in place.
* [Allow Kubit's IP ranges](https://learn.kubit.ai/warehouses/ip-allowlist.md): let Kubit through a firewall.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.