This section explains how to query and interact with data in RisingWave.

RisingWave offers several methods for serving results, catering to various use cases, from ad-hoc analysis to application integration.

Query with SELECT statements

Retrieve data directly from RisingWave using standard SQL SELECT queries against tables or materialized views. Use this method for ad-hoc analysis, exploring the latest results, and extracting specific data subsets.

For syntax details, see SELECT. To learn how RisingWave processes data (ad-hoc or streaming), see Ad-hoc vs. Streaming queries.

Connect to RisingWave with psql or any other PostgreSQL-compatible client to execute these queries. RisingWave is compatible with many data visualization tools. Here are a few that we have tested:

Key features:

  • Uses familiar SQL syntax.
  • Provides immediate access to the most up-to-date results.
  • Offers flexibility to filter, aggregate, and join data.

Example: Retrieve the latest aggregated results from a materialized view.

Integrate with PostgreSQL via foreign data wrapper (FDW)

RisingWave seamlessly integrates with existing PostgreSQL ecosystems through its Foreign Data Wrapper (FDW) functionality. Query data in RisingWave’s tables and materialized views as if it were part of your PostgreSQL database. This allows you to leverage existing PostgreSQL tools and workflows.

For details, see RisingWave as Postgres FDW.

Key features:

  • Enables unified querying across RisingWave and PostgreSQL data.
  • Allows you to use existing PostgreSQL tools and applications.
  • Simplifies integration into existing data infrastructure.
  • Performance: While FDW offers convenience, it may introduce some performance overhead compared to directly querying RisingWave. RisingWave pushes down filters in WHERE clauses to optimize queries. However, complex queries with joins, aggregations, or LIMIT clauses are processed in PostgreSQL after fetching the data from RisingWave.

Example: Join data in a PostgreSQL table with a continuously updated materialized view in RisingWave.

Subscribe to real-time updates

RisingWave’s subscription feature allows you to receive a continuous stream of updates from a materialized view directly, without needing an external message queue. This includes both existing data in the materialized view when the subscription is created and subsequent changes. You can choose to retrieve the full dataset or only incremental changes from a specific point using a subscription cursor.

For details, see Subscription.

Key features:

  • Provides real-time data updates directly from RisingWave.
  • Allows retrieving full or incremental data using a cursor.
  • Requires fewer components and less maintenance than external event stores.

Example: Subscribe to a materialized view that tracks website user activity to power a live dashboard, receiving updates directly from RisingWave.

Access programmatically via SDK and client libraries

RisingWave provides a Python SDK risingwave-py (currently in public preview) to help you develop event-driven applications. The SDK offers a simple way to perform ad-hoc queries, subscribe to changes, and define event handlers for tables and materialized views.

Additionally, since RisingWave is compatible with Postgres, you can use standard PostgreSQL drivers to interact with RisingWave from your applications.

Client libraries in various languages allow developers to interact with RisingWave programmatically and execute SELECT queries within their applications.

For the list of available client libraries, see Client Libraries.

Example: Use the Python client library to fetch the latest results from a materialized view and display them in a financial data analysis application.

Choose the right method

From the methods described above, select the one that best fits your needs, considering factors like query complexity, integration requirements, and team expertise. RisingWave ensures consistency across all methods.