apps/docs/content/guides/storage/analytics/query-with-postgres.mdx
Once your data flows into an analytics bucket through your own ingestion pipeline, you can query it directly from Postgres using standard SQL.
This is made possible by the Iceberg Foreign Data Wrapper, which creates a bridge between your Postgres database and Iceberg tables.
<Admonition type="note" title="About ingestion">Managed replication into Analytics Buckets through Supabase ETL is no longer supported. This guide assumes your Analytics Bucket is being populated by your own ingestion pipeline.
</Admonition>You have two options to enable querying:
The dashboard provides the easiest setup experience:
<Image alt="Query with PostgreSQL button on analytics bucket page" src="/docs/img/storage/query-analytics-with-postgres.png"
width={1860} height={332} />
<Image alt="Select destination PostgreSQL schema" src="/docs/img/storage/query-analytics-schema-name.png"
width={525} height={297} />
Once the foreign data wrapper is installed, you can query your Iceberg tables using standard SQL:
select *
from schema_name.table_name
limit 100;
Get the latest events:
select event_id, event_name, event_timestamp
from analytics.events
order by event_timestamp desc
limit 1000;
Join with transactional data:
SELECT
e.event_id,
e.event_name,
u.user_email
FROM analytics.events e
JOIN public.users u ON e.user_id = u.id
WHERE e.event_timestamp > NOW() - INTERVAL '7 days'
LIMIT 100;
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.