Skip to main content

Overview

Postgres Changes allows you to subscribe to real-time changes in your PostgreSQL database. When a row is inserted, updated, or deleted, Realtime broadcasts the change to all subscribed clients.
Postgres Changes uses PostgreSQL’s replication functionality. Changes are captured from the Write-Ahead Log (WAL) and broadcast to connected clients.

Enable Realtime

Before subscribing to changes, you need to enable Realtime for your tables:

Via Dashboard

  1. Go to the Database page in your Supabase Dashboard
  2. Click on “Replication” in the sidebar
  3. Toggle Realtime for the tables you want to watch

Via SQL

Basic Usage

Listen to All Changes

Subscribe to all events (INSERT, UPDATE, DELETE) on a table:

Listen to Specific Events

Subscribe only to INSERT events:
Available events:
  • INSERT - New rows inserted
  • UPDATE - Existing rows updated
  • DELETE - Rows deleted
  • * - All events

Filter by Column Values

Listen to changes only when specific column values match:
Supported filter operators:
  • eq - Equals
  • neq - Not equals
  • lt - Less than
  • lte - Less than or equal
  • gt - Greater than
  • gte - Greater than or equal

Payload Structure

The payload object contains information about the change:

Event Type Differences

INSERT: new contains the inserted row, old is empty
UPDATE: Both new and old contain data
DELETE: old contains the deleted row, new is empty

Advanced Patterns

Multiple Table Subscriptions

Listen to changes across multiple tables using one channel:

Real-time Dashboard Example

Automatically update a dashboard when metrics change:

Live Query Pattern

Combine initial fetch with real-time updates:

Authorization with RLS

Postgres Changes respects Row Level Security policies. Clients only receive changes for rows they have permission to see.

Enable RLS

Now authenticated users only receive real-time updates for their own messages:
Without RLS policies, all users can see all database changes. Always enable RLS for production applications.

Performance Tips

Limit the Number of Subscriptions

Each subscription creates overhead. Combine related subscriptions when possible:

Use Column Filters

Filter at the database level rather than in your application:

Clean Up Subscriptions

Always unsubscribe when done:

Troubleshooting

No Changes Received

  1. Check if Realtime is enabled for the table in the Dashboard
  2. Verify RLS policies aren’t blocking changes
  3. Confirm subscription status:

Changes Delayed

  • Realtime uses PostgreSQL’s logical replication, which has minimal latency (typically < 100ms)
  • Network conditions affect delivery time
  • Check your project’s health in the Dashboard

Next Steps

Broadcast

Send ephemeral messages between clients

Presence

Track online users in real-time