foreign data wrappers and you with postgres

19
Foreign Data Wrappers and You BRUCE MOMJIAN April, 2015 This talk explains how foreign data wrappers can be used to leverage such connectivity. Creative Commons Attribution License http://momjian.us/presentations 1 / 19

Upload: enterprisedb

Post on 16-Jul-2015

237 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Foreign Data Wrappers and You with Postgres

Foreign Data Wrappers and You

BRUCE MOMJIAN

April, 2015

This talk explains how foreign data wrappers can be used toleverage such connectivity.Creative Commons Attribution License http://momjian.us/presentations

1 / 19

Page 2: Foreign Data Wrappers and You with Postgres

PostgreSQL the database…

! Open Source Object Relational DBMS since 1996

! Distributed under the PostgreSQL License

! Similar technical heritage as Oracle, SQL Server & DB2

! However, a strong adherence to standards (ANSI-SQL 2008)

! Highly extensible and adaptable design

! Languages, indexing, data types, etc.! E.g. PostGIS, JSONB, SQL/MED

! Extensive use throughout the world for applications andorganizations of all types

! Bundled into Red Hat Enterprise Linux, Ubuntu, CentOSand Amazon Linux

Foreign Data Wrappers and You 2 / 19

Page 3: Foreign Data Wrappers and You with Postgres

PostgreSQL the community…

! Independent community led by a Core Team of six

! Large, active and vibrant community

! www.postgresql.org

! Downloads, Mailing lists, Documentation

! Sponsors sampler:

! Google, Red Hat, VMWare, Skype, Salesforce, HP andEnterpriseDB

! http://www.postgresql.org/community/

Foreign Data Wrappers and You 3 / 19

Page 4: Foreign Data Wrappers and You with Postgres

EnterpriseDB the company…

! The worldwide leader of Postgres based products andservices founded in 2004

! Customers include 50 of the Fortune 500 and 98 of theForbes Global 2000

! Enterprise offerings:

! PostgreSQL Support, Services and Training! Postgres Plus Advanced Server with Oracle Compatibility! Tools for Monitoring, Replication, HA, Backup & Recovery

Community

! Citizenship

! Contributor of key features: Materialized Views, JSON, &more

! Nine community members on staff

Foreign Data Wrappers and You 4 / 19

Page 5: Foreign Data Wrappers and You with Postgres

EnterpriseDB the company…

Foreign Data Wrappers and You 5 / 19

Page 6: Foreign Data Wrappers and You with Postgres

Why use Foreign Data Wrappers

Foreign data wrappers allow SQL access to data in:

! Postgres clusters on the same server, perhaps in differentdatabases or clusters

! Remote Postgres servers

! Stored in non-Postgres data repositories! Stored in data repositories with different performance and

storage characteristics

Foreign Data Wrappers and You 6 / 19

Page 7: Foreign Data Wrappers and You with Postgres

Foreign Data Wrappers (Database Federation)Foreign data wrappers (SQL MED) allow queries to read and writedata to foreign data sources. Foreign database support includes:

! CouchDB! Hadoop! Informix! MongoDB! MySQL! Neo4j! Oracle! Postgres! Redis

The transfer of joins, aggregates, and sorts to foreign servers is not yetimplemented.EnterpriseDB Advanced Server’s database links provide similarfunctionality for Oracle.http://www.postgresql.org/docs/current/static/ddl-foreign-data.htmlhttp://wiki.postgresql.org/wiki/Foreign_data_wrappers

Foreign Data Wrappers and You 7 / 19

Page 8: Foreign Data Wrappers and You with Postgres

Foreign Data Wrappers to Interfaces

! JDBC

! LDAP

! ODBC

Foreign Data Wrappers and You 8 / 19

Page 9: Foreign Data Wrappers and You with Postgres

Foreign Data Wrappers toNon-Traditional Data Sources

! Files

! HTTP

! AWS S3

! Twitter

Foreign Data Wrappers and You 9 / 19

Page 10: Foreign Data Wrappers and You with Postgres

Foreign Data Wrapper Example

CREATE SERVER postgres_fdw_test

FOREIGN DATA WRAPPER postgres_fdw

OPTIONS (host ’localhost’, dbname ’fdw_test’);

CREATE USER MAPPING FOR PUBLIC

SERVER postgres_fdw_test

OPTIONS (password ’’);

CREATE FOREIGN TABLE other_world (greeting TEXT)

SERVER postgres_fdw_test

OPTIONS (table_name ’world’);

\detList of foreign tablesSchema | Table | Server--------+-------------+-------------------public | other_world | postgres_fdw_test(1 row)

Foreign Postgres server name in red; foreign table name in blue

Foreign Data Wrappers and You 10 / 19

Page 11: Foreign Data Wrappers and You with Postgres

Read and Read/Write Data Sources

Postgresora_tab

tw_tab

mon_tabMongoDB

Twitter

Oracle

Foreign Data Wrappers and You 11 / 19

Page 12: Foreign Data Wrappers and You with Postgres

Complex FDW Capabilities

! Table restriction pushdown (supported by the postgres_fdw)

! Join/aggregate/sort pushdown to FDW sources that support it

! Parallel FDW access

! Cross-server snapshot synchronization (perhaps possiblewith serialization control)

! Cross-server transaction durability (possible with two-phasecommit or XA transactions)

Foreign Data Wrappers and You 12 / 19

Page 13: Foreign Data Wrappers and You with Postgres

Foreign Data Wrapper Pushdown (FDW)SQL Queries

SQL Queries

PG FDW

Foreign Server Foreign Server Foreign Server

Foreign Data Wrappers and You 13 / 19

Page 14: Foreign Data Wrappers and You with Postgres

FDW Sort/Join/Aggregate PushdownSQL Queries

SQL Queries

PG FDW

with joins, sorts, aggregates

Foreign Server Foreign Server Foreign Server

Foreign Data Wrappers and You 14 / 19

Page 15: Foreign Data Wrappers and You with Postgres

Parallel FDW AccessSQL Queries

PG FDW

Parallel Queries

Foreign Server Foreign Server Foreign Server

Foreign Data Wrappers and You 15 / 19

Page 16: Foreign Data Wrappers and You with Postgres

Global Snapshot Manager

SQL Queries

SQL Queries

ManagerGlobal Snapshot

PG FDW

Foreign Server Foreign Server Foreign Server

Foreign Data Wrappers and You 16 / 19

Page 17: Foreign Data Wrappers and You with Postgres

Global Transaction Manager

SQL Queries

SQL Queries

Foreign Server

ManagerGlobal Transaction

PG FDW

Foreign Server Foreign Server

Foreign Data Wrappers and You 17 / 19

Page 18: Foreign Data Wrappers and You with Postgres

Additional Resources…

! Postgres Downloads:

! www.enterprisedb.com/downloads

! Product and Services information:

! [email protected]

Foreign Data Wrappers and You 18 / 19

Page 19: Foreign Data Wrappers and You with Postgres

Conclusion

http://momjian.us/presentations http://flickr.com/photos/vpickering/3617513255

Foreign Data Wrappers and You 19 / 19