1

insert into my_foreign_table select * from my_local_table

My columns are two integers and two floats. The number of rows was >100M. I left it running for a few days, but killed it because it took forever.

Should this run quickly? Does Postgres do the inserts one at a time or something? Is there a way to speed inserts up via foreign data wrapper?

1
  • 1
    Maybe provide details of the machines involved and the network between them? Accompany that with timings for 100,000 rows and you stand a chance of getting a useful answer. Commented Jul 2, 2024 at 17:09

1 Answer 1

3

You can change the batch_size:

ALTER SERVER name_of_your_foreign_server OPTIONS (SET batch_size '1000');

batch_size (integer) This option specifies the number of rows postgres_fdw should insert in each insert operation. It can be specified for a foreign table or a foreign server. The option specified on a table overrides an option specified for the server. The default is 1.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.