Migrate to Snowflake Postgres
Why Migrate?
Snowflake Postgres gives you a fully managed, 100%-compatible PostgreSQL database with enterprise capabilities built in:
- Zero code changes — Full PostgreSQL compatibility means your schemas, queries, stored procedures, and extensions work without modification.
- Enterprise security — PrivateLink, VPC peering, customer-managed encryption keys, and Snowflake's unified access control.
- Built-in high availability — Automated replication and failover with no manual configuration.
- Managed operations — Automated backups (10-day retention), minor version upgrades, monitoring, and alerting are included.
- Platform integration — Access Cortex AI, Streamlit, and the broader Snowflake ecosystem directly from your Postgres data via pg_lake.
Step 1: Assess Your Current Deployment
Before migrating, inventory your existing setup:
Postgres Version and Extensions
SELECT version(); SELECT extname, extversion FROM pg_extension ORDER BY extname;
Verify that your Postgres version and extensions are supported on Snowflake Postgres. Check the compatibility matrix for details.
Database Size and Storage
SELECT pg_size_pretty(pg_database_size(current_database())) AS db_size; SELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname || '.' || tablename)) AS total_size FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema') ORDER BY pg_total_relation_size(schemaname || '.' || tablename) DESC LIMIT 20;
Application Connections
Document every application, service, and tool that connects to your database:
- Connection strings and hosts
- ORMs and database drivers in use
- Connection poolers (PgBouncer, pgpool)
- Scheduled jobs and cron tasks
- Monitoring and backup agents
Custom Configurations
Export your current configuration for reference:
SELECT name, setting, source FROM pg_settings WHERE source NOT IN ('default', 'override') ORDER BY name;
Step 2: Provision Snowflake Postgres
Create your target instance in Snowsight:
Cloud Region
Select the cloud provider (AWS or Azure) and region closest to your application servers to minimize latency.
Instance Family and Size
Choose based on your assessment:
- Match or exceed your current CPU and memory allocation.
- Start with a comparable size — you can resize later without downtime.
Networking
Configure network access to match your security requirements:
- Network policies — Restrict access to specific IP ranges.
- PrivateLink — For private connectivity from your VPC.
- VPC peering — For direct network connectivity without traversing the public internet.
Authentication
Set up users and roles to match your current access patterns. Snowflake Postgres supports standard Postgres authentication methods.
Step 3: Migrate Your Data
Logical Backup with pg_dump / pg_restore
For most databases, a logical backup is the simplest approach:
# Export from source pg_dump -h <source-host> -U <source-user> -d <source-db> \ --format=custom --compress=9 \ -f backup.dump # Import to Snowflake Postgres pg_restore -h <snowflake-host> -U <snowflake-user> -d <target-db> \ --no-owner --no-privileges \ backup.dump
Large Tables with COPY
For very large tables, COPY can be faster than pg_dump:
# Export psql -h <source-host> -U <source-user> -d <source-db> \ -c "\COPY large_table TO 'large_table.csv' WITH CSV HEADER" # Import psql -h <snowflake-host> -U <snowflake-user> -d <target-db> \ -c "\COPY large_table FROM 'large_table.csv' WITH CSV HEADER"
Validate Data Integrity
After migration, verify that all data transferred correctly:
-- Compare row counts SELECT 'customers' AS table_name, COUNT(*) AS row_count FROM customers UNION ALL SELECT 'orders', COUNT(*) FROM orders UNION ALL SELECT 'products', COUNT(*) FROM products; -- Verify constraints SELECT conname, contype, conrelid::regclass FROM pg_constraint WHERE connamespace = 'public'::regnamespace; -- Check indexes SELECT indexname, tablename, indexdef FROM pg_indexes WHERE schemaname = 'public';
Compare these results against your source database to confirm a complete migration.
Step 4: Update Application Connections
Update Connection Strings
Replace your source database host with the Snowflake Postgres endpoint. The port (5432), database name, and SSL mode remain standard Postgres.
# Before postgresql://user:pass@old-host.example.com:5432/mydb?sslmode=require # After postgresql://user:pass@<snowflake-instance-host>:5432/mydb?sslmode=require
Test with Your ORM
Run your application's ORM migrations and seed scripts against the new instance to verify compatibility:
# Django python manage.py migrate --run-syncdb python manage.py test # Rails bundle exec rails db:migrate bundle exec rails test # Node.js (Prisma) npx prisma migrate deploy npm test
Verify Queries and Transactions
- Run your application's test suite against the Snowflake Postgres instance.
- Check that prepared statements, advisory locks, and LISTEN/NOTIFY work as expected.
- Validate transaction isolation behavior if your application relies on specific levels.
Step 5: Enable Snowflake Integration
Once your database is running on Snowflake Postgres, unlock platform features:
pg_lake
Install the pg_lake extension to sync Postgres tables to Snowflake for analytics and AI:
CREATE EXTENSION IF NOT EXISTS pg_lake;
Configure tables for continuous replication to the Snowflake data platform.
Data Pipelines
With your data in Snowflake via pg_lake, you can:
- Join Postgres data with data from other Snowflake sources.
- Build ELT pipelines using Snowflake Tasks and Streams.
- Share data across your organization using Snowflake Data Sharing.
Cortex AI
Use Snowflake Cortex to run LLM functions directly on your synced Postgres data — summarization, classification, translation, and more — without moving data to external services.
Streamlit Dashboards
Build interactive applications on your Postgres data using Streamlit in Snowflake. No frontend framework or separate hosting required.
Conclusion
You have migrated your Postgres database to Snowflake with zero code changes and enabled platform integrations that were not available in your previous environment.
Related Resources
Step-by-step guide to migrating with minimal downtime using logical replication.
Overview of Snowflake Postgres features and capabilities.
Connection methods and client configuration for Snowflake Postgres.
This content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances