Skip to content

Add information around publication creation for postgres and its implications on billing #4190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ Connect to your Aurora PostgreSQL writer instance as an admin user and execute t
4. Create a publication for replication:

```sql
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

:::note

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

## Configure network access {#configure-network-access}

### IP-based access control {#ip-based-access-control}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ Connect to your Azure Flexible Server Postgres through the admin user and run th
4. Create publication that you'll be using for creating the MIRROR (replication) in future.

```sql
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

:::note

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

5. Set `wal_sender_timeout` to 0 for `clickpipes_user`

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ Connect to your Crunchy Bridge Postgres through the `postgres` user and run the
4. Create publication that you'll be using for creating the MIRROR (replication) in future.

```sql
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

:::note

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

## Safe list ClickPipes IPs {#safe-list-clickpipes-ips}

Safelist [ClickPipes IPs](../../index.md#list-of-static-ips) by adding the Firewall Rules in Crunchy Bridge.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ For this, you can connect to your Postgres instance and run the following SQL co
ALTER USER clickpipes_user REPLICATION;

-- Create a publication. We will use this when creating the pipe
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```
:::note

Make sure to replace `clickpipes_user` and `clickpipes_password` with your desired username and password.

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

## Enabling connections in pg_hba.conf to the ClickPipes User {#enabling-connections-in-pg_hbaconf-to-the-clickpipes-user}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ Connect to your Cloud SQL Postgres through the admin user and run the below comm
4. Create publication that you'll be using for creating the MIRROR (replication) in future.

```sql
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

:::note

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

[//]: # (TODO Add SSH Tunneling)

## Add ClickPipes IPs to Firewall {#add-clickpipes-ips-to-firewall}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ Here, we can run the following SQL commands:
ALTER USER clickpipes_user REPLICATION;

-- Create a publication. We will use this when creating the mirror
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

<Image size="lg" img={neon_commands} alt="User and publication commands" border/>

:::note

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

Click on **Run** to have a publication and a user ready.

## Enable logical replication {#enable-logical-replication}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
---
sidebar_label: 'Publication Management'
description: 'Best practices for managing PostgreSQL publications with ClickPipes'
slug: /integrations/clickpipes/postgres/source/publication-management
title: 'PostgreSQL Publication Management for ClickPipes'
---

# PostgreSQL Publication Management for ClickPipes

This guide covers best practices and considerations for managing PostgreSQL publications when using ClickPipes for data replication.

## Publication Creation Options {#publication-creation-options}

You have two main approaches for managing publications with ClickPipes:

### Option 1: Automatic Publication Creation (Let ClickPipes Manage It) {#automatic-publication-creation}

If you want ClickPipes to handle publication management and not worry about the intricacies of PostgreSQL publications, simply **don't specify a publication** during ClickPipe creation. ClickPipes will automatically create a publication scoped to only the tables you select for replication.

**Requirements:**
- The ClickPipes user must have **table owner permissions** for all tables you want to replicate

**Advantages:**
- No manual publication management required
- Publication is automatically scoped to only selected tables
- Same cost-effective billing as table-specific publications (only pay for selected tables)
- Easiest approach for getting started

**Disadvantages:**
- Requires higher privileges (table owner permissions)
- If you add tables to the pipe later, ClickPipes will need to modify the publication, requiring continued owner permissions

### Option 2: Manual Publication Creation (Recommended for Production) {#manual-publication-creation}

Create and manage the publication yourself before setting up the ClickPipe.

#### Table-Specific Publication (Recommended) {#table-specific-publication}

```sql
-- Create a publication for specific tables you wish to replicate
-- Replace 'schema.table1', 'schema.table2' with your actual schema and table names
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

**Advantages:**
- Fine-grained control over which tables are included
- Only requires SELECT permissions on tables (not ownership)
- Clear visibility into what data will be replicated
- Same cost-effective billing as automatic creation (only pay for selected tables)

**Disadvantages:**
- Manual management required
- Must update publication when adding/removing tables from replication

#### All-Tables Publication (Use with Caution) {#all-tables-publication}

```sql
-- Creates publication for all current and future tables
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
```

**Important Considerations:**
- Though ClickPipes will only replicate tables you select in the UI, PostgreSQL will send data changes from **all tables** over the network
- **You will be billed for the extra bytes** from tables you don't actually need
- This approach is generally not recommended for production use

## Permission Requirements {#permission-requirements}

### For Automatic Publication Creation {#automatic-permissions}
```sql
-- Grant table ownership (required for automatic publication creation)
ALTER TABLE schema.table1 OWNER TO clickpipes_user;
ALTER TABLE schema.table2 OWNER TO clickpipes_user;
```

### For Manual Publication Creation {#manual-permissions}
```sql
-- Minimal permissions (sufficient for manual publication approach)
GRANT USAGE ON SCHEMA "your_schema" TO clickpipes_user;
GRANT SELECT ON TABLE schema.table1, schema.table2 TO clickpipes_user;
ALTER USER clickpipes_user REPLICATION;

-- If you need to grant permissions for future tables in the schema:
ALTER DEFAULT PRIVILEGES IN SCHEMA "your_schema" GRANT SELECT ON TABLES TO clickpipes_user;
```

## Managing Publications Over Time {#managing-publications-over-time}

### Adding Tables to an Existing Publication {#adding-tables}

If you need to add tables to your ClickPipe later:

```sql
-- Add a single table
ALTER PUBLICATION clickpipes_publication ADD TABLE schema.new_table;

-- Add multiple tables
ALTER PUBLICATION clickpipes_publication ADD TABLE schema.table3, schema.table4;
```

### Removing Tables from a Publication {#removing-tables}

```sql
-- Remove a single table
ALTER PUBLICATION clickpipes_publication DROP TABLE schema.old_table;

-- Remove multiple tables
ALTER PUBLICATION clickpipes_publication DROP TABLE schema.table3, schema.table4;
```

### Viewing Publication Contents {#viewing-publication-contents}

```sql
-- See which tables are in your publication
SELECT schemaname, tablename
FROM pg_publication_tables
WHERE pubname = 'clickpipes_publication';

-- See all publications
SELECT * FROM pg_publication;
```

## Best Practices {#best-practices}

1. **Choose either automatic creation or table-specific publications** for production workloads - both provide the same cost control, with automatic being easier and manual providing more control

2. **Use automatic creation** when you want ClickPipes to handle publication management and don't mind granting table owner privileges

3. **Plan your table selection carefully** - adding/removing tables later requires publication changes

4. **Avoid all-tables publications** unless you specifically need all tables - this is the only approach that increases costs

5. **Monitor your data usage** to ensure you're only paying for data you actually need

6. **Document your publication strategy** so team members understand the setup

## Billing Implications {#billing-implications}

- **Table-specific publications**: You pay only for data changes from explicitly listed tables
- **Automatic creation**: You pay only for data changes from selected tables (same cost as table-specific)
- **All-tables publications**: You pay for data changes from **all tables** in the database, even if ClickPipes only processes a subset - this is the costly approach to avoid

## Additional Resources {#additional-resources}

For more advanced publication options and syntax, see the [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-createpublication.html).

## Troubleshooting {#troubleshooting}

### Permission Errors {#permission-errors}
If you encounter permission errors:
1. Verify the ClickPipes user has the required permissions for your chosen approach
2. Check that the publication exists and contains the expected tables
3. Ensure the user has REPLICATION privileges

### Unexpected Billing {#unexpected-billing}
If you're seeing higher than expected data transfer costs:
1. Check if you're using an all-tables publication unintentionally
2. Verify your publication only contains the tables you need
3. Monitor which tables are actively changing in your database
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ Connect to your RDS Postgres instance as an admin user and execute the following
4. Create a publication for replication:

```sql
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

:::note

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

## Configure network access {#configure-network-access}

### IP-based access control {#ip-based-access-control}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ Here, we can run the following SQL commands:
ALTER USER clickpipes_user REPLICATION;

-- Create a publication. We will use this when creating the mirror
CREATE PUBLICATION clickpipes_publication FOR ALL TABLES;
CREATE PUBLICATION clickpipes_publication FOR TABLE schema.table1, schema.table2;
```

<Image img={supabase_commands} alt="User and publication commands" size="large" border/>

:::note

For detailed information about publication management, including automatic creation, table-specific vs all-tables publications, and billing implications, see our [Publication Management Guide](./publication-management.md).

:::

Click on **Run** to have a publication and a user ready.

:::note
Expand Down
Loading