Skip to main content
RisingWave allows you to query PostgreSQL tables directly with the postgres_query table-valued function (TVF). It offers a simpler alternative to Change Data Capture (CDC) when working with PostgreSQL data in RisingWave. Unlike CDC, which continuously syncs data changes, this function lets you fetch data directly from PostgreSQL when needed. Therefore, this approach is ideal for static or infrequently updated data, as it’s more resource-efficient than maintaining a constant CDC connection.
Not CDC. This approach fetches rows on demand via a table-valued function. For continuous change replication, use PostgreSQL CDC.

Syntax

Define postgres_query in either of the following forms:
The source-based form requires an existing PostgreSQL CDC source. It reuses the connection properties already defined on that source, including credentials managed as secrets.

Example

  1. In your PostgreSQL database, create a table and populate it with sample data.
  1. In RisingWave, use postgres_query function to retrieve rows where id > 90.
If you already have a PostgreSQL CDC source, you can reuse its connection properties instead of passing them inline again.