Query Federation via PostgreSQL
Postgres-Compatible Query Layer for BigQuery and Snowflake
You can use PeerDB’s Postgres-compatible SQL layer to query tables in BigQuery or Snowflake. You can leverage Postgres’ hundreds of integrations, including client tools like pgadmin and psql, BI tools like Grafana and Power BI, and languages such as Python and Ruby to query data in BigQuery or Snowflake.
PeerDB parses and translates the incoming SQL query to make it compatible with the appropriate Peer. It pushes down most SQL constructs, including filters, JOINs, aggregates, sorts, limits etc., to the attached Peer. This enables blazing fast performance.
You can also query tables in BigQuery or Snowflake from your existing Postgres database by connecting PeerDB as a postgres_fdw
FOREIGN SERVER.
You can utilize postgres_fdw’s advance push-down capabilities to maximize the performance of your queries involving BigQuery and Snowflake tables. For queries where push-down is important, you can expect 100x performance gains compared to other foreign data wrappers.
Let’s go through steps to query BigQuery and Snowflake using PeerDB.
Step 1: Add BigQuery and Snowflake Peers
Run the following commands to let PeerDB know about the existing Postgres and Snowflake Peers:
Make sure to replace (…)
with the appropriate connection details for both the Postgres and Snowflake instances. More details on adding PEERs are available here.
Step 2: Query Tables in BigQuery and Snowflake
You can find different variations of queries that should work out of the box for BigQuery and Snowflake in the provided links. Currently, only SELECT commands are supported, while DML and DDL commands are not yet.
Query BigQuery and Snowflake using postgres_fdw
PeerDB enables you to query BigQuery or Snowflake from your existing Postgres database using postgres_fdw
. As PeerDB is Postgres wire-compatible, you can connect to PeerDB as a postgres_fdw FOREIGN SERVER from your Postgres database and start querying tables in Peers that have been created on PeerDB.
Let’s walk through the steps to query tables in BigQuery from your existing Postgres database using PeerDB.
Step 1: Create PeerDB as a FOREIGN SERVER to your Postgres database
Step 2: Create FOREIGN TABLE on Postgres pointing to tables in BigQuery
Step 3: Start querying BigQuery FOREIGN TABLE from Postgres
Step 4: Join local Postgres tables with the BigQuery FOREIGN TABLE
Support
If you run into any issues, join our slack channel and reach out to us. You can file an issue on our gihub repository or reach out to founders@peerdb.io . We will follow up!