Re: Proposal to CREATE FOREIGN TABLE LIKE

From: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal to CREATE FOREIGN TABLE LIKE
Date: 2025-02-01 13:39:10
Message-ID: db68bd6f-6085-4152-8799-82ac929b256d@Spark
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Zhang Mingli
www.hashdata.xyz
On Feb 1, 2025 at 20:20 +0800, Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, wrote:
>
> Sure. Did you consider IMPORT FOREIGN SCHEMA?
Hi, Álvaro

Thank you very much for your suggestion.

I've looked into it, and it certainly can be beneficial, especially for postgres_fdw.
However, I believe that not all FDWs support the concept of a schema or can be used with the IMPORT FOREIGN SCHEMA command, is it?

For example, we use kafka_fdw to produce and consume data from a Kafka server.
In our scenario, we sometimes need to write records from a local table into Kafka. Here’s a brief outline of our process:

1. We already have a wide table, local_wide_table in Postgres.
2. We need to create a foreign table, foreign_table, with the same definition as local_wide_table.
3. Insert records into foreign_table by selecting from local_wide_table with the some quals.

In step 2, we currently have to manually create the foreign table using CREATE FOREIGN TABLE and copy the column definitions one by one.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ants Aasma 2025-02-01 14:43:41 Re: hash_search_with_hash_value is high in "perf top" on a replica
Previous Message Álvaro Herrera 2025-02-01 12:20:17 Re: Proposal to CREATE FOREIGN TABLE LIKE