Skip to content
Storage

用 Postgres 查询

Query analytics bucket data directly from Postgres using SQL.

一旦你的数据通过自己的采集管道流入分析桶,你就可以直接用标准 SQL 在 Postgres 上查询它。

🌐 Once your data flows into an analytics bucket through your own ingestion pipeline, you can query it directly from Postgres using standard SQL.

这是通过 Iceberg Foreign Data Wrapper 实现的,它在你的 Postgres 数据库和 Iceberg 表之间创建了一座桥梁。

🌐 This is made possible by the Iceberg Foreign Data Wrapper, which creates a bridge between your Postgres database and Iceberg tables.

设置概览 #

🌐 Setup overview

你有两个选项可以启用查询:

🌐 You have two options to enable querying:

  1. 仪表板界面(推荐)- 通过 Supabase 仪表板简化设置
  2. 手动安装 - 使用 SQL 和配置来安装封装器

通过仪表板界面安装 #

🌐 Installing via Dashboard UI

这个仪表板提供了最简单的设置体验:

🌐 The dashboard provides the easiest setup experience:

  1. 在 Supabase 仪表板中导航到你的 分析桶 页面。
  2. 找到你想查询的命名空间,然后点击 用 Postgres 查询
Query with Postgres button on analytics bucket page
  1. 输入你想创建外部表的 Postgres 模式
Select destination Postgres schema
  1. 点击 连接。封装器现在已配置好。

查询你的数据 #

🌐 Querying your data

一旦安装了外部数据封装器,你就可以用标准 SQL 查询你的 Iceberg 表了:

🌐 Once the foreign data wrapper is installed, you can query your Iceberg tables using standard SQL:

1
select *
2
from schema_name.table_name
3
limit 100;

常见查询示例 #

🌐 Common query examples

获取最新活动:

🌐 Get the latest events:

1
select event_id, event_name, event_timestamp
2
from analytics.events
3
order by event_timestamp desc
4
limit 1000;

与交易数据关联:

🌐 Join with transactional data:

1
SELECT
2
e.event_id,
3
e.event_name,
4
u.user_email
5
FROM analytics.events e
6
JOIN public.users u ON e.user_id = u.id
7
WHERE e.event_timestamp > NOW() - INTERVAL '7 days'
8
LIMIT 100;

手动安装 #

🌐 Manual installation

对于高级用例,你可以手动安装并配置 Iceberg 外部数据封装器。有关详细说明,请参阅 Iceberg 外部数据封装器文档

🌐 For advanced use cases, you can manually install and configure the Iceberg Foreign Data Wrapper. See the Iceberg Foreign Data Wrapper documentation for detailed instructions.