From f1cf6c642dfe6c1d6b11bdee16f01cb4752343e1 Mon Sep 17 00:00:00 2001 From: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:31:18 -0500 Subject: [PATCH] added postgres_fdw docs (#31085) * added postgres_fdw docs * updated link in extension docs * Update apps/docs/content/guides/database/extensions/postgres_fdw.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update apps/docs/content/guides/database/extensions/postgres_fdw.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update apps/docs/content/guides/database/extensions/postgres_fdw.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * ci: Autofix updates from GitHub workflow * Update apps/docs/content/guides/database/extensions/postgres_fdw.mdx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --------- Co-authored-by: Brian Brennglass Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-tidy-bot Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --- .../NavigationMenu.constants.ts | 4 + .../database/extensions/postgres_fdw.mdx | 148 ++++++++++++++++++ packages/shared-data/extensions.json | 2 +- .../config/vocabularies/Supabase/accept.txt | 3 + 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 apps/docs/content/guides/database/extensions/postgres_fdw.mdx diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts index 524457ab66..9cb1e92666 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts @@ -1004,6 +1004,10 @@ export const database: NavMenuConstant = { name: 'pg_stat_monitor: Extended Query Performance Monitoring', url: '/guides/database/extensions/pg_stat_monitor', }, + { + name: 'postgres_fdw: query data from an external Postgres server', + url: '/guides/database/extensions/postgres_fdw', + }, { name: 'pgvector: Embeddings and vector similarity', url: '/guides/database/extensions/pgvector', diff --git a/apps/docs/content/guides/database/extensions/postgres_fdw.mdx b/apps/docs/content/guides/database/extensions/postgres_fdw.mdx new file mode 100644 index 0000000000..2d1e6703e9 --- /dev/null +++ b/apps/docs/content/guides/database/extensions/postgres_fdw.mdx @@ -0,0 +1,148 @@ +--- +id: 'postgres_fdw' +title: 'postgres_fdw' +description: 'Query Postgres server from another' +--- + +The extension enables Postgres to query tables and views on a remote Postgres server. + +## Enable the extension + + + + + 1. Go to the [Database](/dashboard/project/_/database/tables) page in the Dashboard. + 2. Click on **Extensions** in the sidebar. + 3. Search for "postgres_fdw" and enable the extension. + + + + + ```sql + -- Example: enable the "postgres_fdw" extension + create extension if not exists postgres_fdw; + + -- Example: disable the "postgres_fdw" extension + drop extension if exists postgres_fdw; + ``` + + Procedural languages are automatically installed within `pg_catalog`, so you don't need to specify a schema. + + + + + +## Create a connection to another database + + + + + + Define the remote database address + + + + ```sql + create server "" + foreign data wrapper postgres_fdw + options ( + host '', + port '', + dbname '' + ); + ``` + + + + + + Set the user credentials for the remote server + + + ```sql + create user mapping for "" + server "" + options ( + user '', + password '' + ); + ``` + + + + + + Import tables from the foreign database + + + Example: Import all tables from a schema + ```sql + import foreign schema "" + from server "" + into ""; + ``` + + Example: Import specific tables + ```sql + import foreign schema """ + limit to ( + "", + "" + ) + from server "" + into ""; + ``` + + + + + + + ```sql + select * from '' + ``` + + + + + +### Configuring execution options + +#### Fetch_size + +Maximum rows fetched per operation. For example, fetching 200 rows with `fetch_size` set to 100 requires 2 requests. + +```sql +alter server "" +options (fetch_size '10000'); +``` + +#### Batch_size + +Maximum rows inserted per cycle. For example, inserting 200 rows with `batch_size` set to 100 requires 2 requests. + +```sql +alter server "" +options (batch_size '1000'); +``` + +#### Extensions + +Lists shared extensions. Without them, queries involving unlisted extension functions or operators may fail or omit references. + +```sql +alter server "" +options (extensions 'vector, postgis'); +``` + +For more server options, check the extension's [official documentation](https://www.postgresql.org/docs/current/postgres-fdw.html#POSTGRES-FDW) + +## Resources + +- Official [`postgres_fdw` documentation](https://www.postgresql.org/docs/current/postgres-fdw.html#POSTGRES-FDW) diff --git a/packages/shared-data/extensions.json b/packages/shared-data/extensions.json index 527ea514f6..c1752b0abe 100644 --- a/packages/shared-data/extensions.json +++ b/packages/shared-data/extensions.json @@ -487,7 +487,7 @@ "name": "postgres_fdw", "comment": "foreign-data wrapper for remote PostgreSQL servers", "tags": ["Admin"], - "link": "https://www.postgresql.org/docs/current/postgres-fdw.html", + "link": "/guides/database/extensions/postgres_fdw", "github_url": null, "product": null, "product_url": null diff --git a/vale/styles/config/vocabularies/Supabase/accept.txt b/vale/styles/config/vocabularies/Supabase/accept.txt index 50cf9cd707..dbe3156268 100644 --- a/vale/styles/config/vocabularies/Supabase/accept.txt +++ b/vale/styles/config/vocabularies/Supabase/accept.txt @@ -1,6 +1,7 @@ APIs [Aa]uth [Bb]aselining +batch_size Berri [Cc]hatbots? ChatGPT @@ -24,6 +25,7 @@ Deno [Ee]nv [Ee]nums? event_message +fetch_size Firestore Hashicorp [Gg]eospatial @@ -41,6 +43,7 @@ JWTs Lua Markprompt [Mm]iddleware +misexecution [Nn]amespace(d|s)? Next.js npm