mongo_fdw
mongo_fdw · foreign data wrapper for MongoDB access
Overview
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | documentdb pg_projection pgbson jsquery pgjq pg_jsonschema jsonschema redis_fdw etcd_fdw rdf_fdw |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| el8.aarch64 | N/A | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| el9.x86_64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| el9.aarch64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| el10.x86_64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| el10.aarch64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| d12.x86_64 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 |
| d12.aarch64 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 |
| d13.x86_64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| d13.aarch64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| u22.x86_64 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 |
| u22.aarch64 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 |
| u24.x86_64 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 |
| u24.aarch64 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 | PIGSTY 5.6.0 |
| u26.x86_64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
| u26.aarch64 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 | PGDG 5.6.0 |
Source
github.com/EnterpriseDB/mongo_fdw
mongo_fdw-REL-5_6_0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
mongo_fdw 5.6.0 reads and writes MongoDB collections from PostgreSQL 14–19. Its SQL/control version remains 1.1. Install the matching MongoDB client libraries and create the extension as a superuser; shared preload is unnecessary.
Map a Collection
For an existing collection, configure an account with the intended remote privileges:
The first foreign-table column must be _id of type name. Let MongoDB create valid identifiers rather than inventing short ObjectId strings. Column types must match the BSON representation. Use INSERT, UPDATE and DELETE only with the expected remote permissions and identifier mapping; remote writes are not a substitute for a distributed transaction protocol.
Connection and Planning
Server options include authentication_database, replica_set, read_preference and TLS certificate settings. Restrict user-mapping credentials and verify the remote certificate. The foreign-table options database and collection select data. This FDW does not implement IMPORT FOREIGN SCHEMA.
Join, aggregate, ordering and limit pushdown are controlled by the server/table options and session GUCs. mongo_fdw.log_remote_query helps diagnose pushed queries. BSON text requires UTF8. Quote nested or uppercase field names; field names starting with a dollar sign or containing one after a dot are unsupported.
Changes and Upgrade Checks
5.6.0 fixes URI-option injection and short-identifier out-of-bounds reads. Cursor failures now raise errors rather than silently returning no rows. BSON doubles converted to integer types round to the nearest integer; non-finite and out-of-range input raises an error. Test applications that depended on truncation or hidden errors.
Aggregate pushdown can bypass that integer-input validation: non-finite source values may survive in a remote aggregate. Set mongo_fdw.enable_aggregate_pushdown to false when local validation is required. Install the new binary and reconnect sessions; the SQL version stays 1.1. Verify row counts, identifiers and query plans against representative remote data after upgrading.