Overview
The Data Warehouse provides:- External data syncing - Connect to databases, SaaS tools, and data warehouses
- SQL querying - Use HogQL to query external tables alongside PostHog events
- Saved queries and views - Create reusable data models and materialized views
- Real-time joins - Combine external data with product analytics
- Usage tracking - Monitor rows synced and materialized
Supported Data Sources
Connect to databases, SaaS platforms, and data warehouses:Sync Configuration
Incremental Syncing
Use incremental syncing to only sync new or updated rows:Incremental fields - Must be monotonically increasing (timestamp, integer ID)
and present on every row for reliable syncing.
Full Table Syncs
For smaller tables or when you need complete refreshes:Append-Only Syncs
For event streams and immutable logs:Querying External Data
Basic SQL Queries
Query external tables using HogQL:Joining with Product Data
Combine external data with PostHog events:Saved Queries and Views
Creating Views
Save reusable queries as views:Materialized Views
Enable materialization for faster queries on large datasets:1
Create the view
First create a standard saved query with your SQL logic.
2
Enable materialization
3
Query materialized table
Once materialized, query the view like any table:
Materialized views are refreshed on schedule and stored as ClickHouse tables.
They’re ideal for complex aggregations that power dashboards.
Schema Management
Refreshing Schemas
Fetch the latest table list from a source:Managing Table Prefixes
Use prefixes when connecting multiple instances of the same source:Monitoring and Usage
Sync Statistics
Track data warehouse usage:Job Status
Monitor sync jobs:Data Health Issues
Get failed syncs and materializations:SSH Tunneling
Connect to databases behind firewalls using SSH tunnels:Revenue Analytics (Stripe)
For Stripe sources, enable automatic revenue analytics:- Customer lifetime value
- Revenue by cohort
- Churn analysis
API Reference
Create External Data Source
Trigger Manual Sync
Delete Source
Best Practices
Incremental Syncing
Use incremental syncing for large tables. Ensure incremental fields are indexed
and monotonically increasing (timestamps, auto-increment IDs).
Materialized Views
Materialize complex aggregations that power dashboards. Schedule refreshes during
off-peak hours to minimize impact on source databases.
Schema Prefixes
Use prefixes when connecting multiple instances (prod/staging) of the same source
to avoid naming conflicts.
SSH Tunnels
For production databases, use SSH tunneling with key-based auth instead of
exposing databases directly to the internet.
Troubleshooting
Connection Timeouts
If syncs fail with connection timeouts:- Verify firewall rules allow PostHog IPs
- Check database connection limits
- Consider using SSH tunneling for stable connections
Incremental Field Issues
Common mistake: Using non-monotonic fields like
last_login which can decrease.
Always use created_at, updated_at, or auto-increment IDs.