- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit97da482

Etsuro Fujita
Allow batch insertion during COPY into a foreign table.
Commit3d956d9 allowed the COPY, but it's done by inserting individualrows to the foreign table, so it can be inefficient due to the overheadcaused by each round-trip to the foreign server. To improve performanceof the COPY in such a case, this patch allows batch insertion, byextending the multi-insert machinery in CopyFrom() to the foreign-tablecase so that we insert multiple rows to the foreign table at once usingthe FDW callback routine added by commitb663a41. This patch alsoallows this for postgres_fdw. It is enabled by the "batch_size" optionadded by commitb663a41, which is disabled by default.When doing batch insertion, we update progress of the COPY command afterperforming the FDW callback routine, to count rows not suppressed by theFDW as well as a BEFORE ROW INSERT trigger. For consistency, this patchchanges the timing of updating it for plain tables: previously, weupdated it immediately after adding each row to the multi-insert buffer,but we do so only after writing the rows stored in the buffer out to thetable using table_multi_insert(), which I think would be consistent evenwith non-batching mode, because in that mode we update it after writingeach row out to the table using table_tuple_insert().Andrey Lepikhov, heavily revised by me, with review from Ian Barwick,Andrey Lepikhov, and Zhihong Yu.Discussion:https://postgr.es/m/bc489202-9855-7550-d64c-ad2d83c24867%40postgrespro.ru1 parent56c19fe commit97da482
File tree
7 files changed
+460
-89
lines changed- contrib/postgres_fdw
- expected
- sql
- doc/src/sgml
- src
- backend/commands
- include/commands
7 files changed
+460
-89
lines changedLines changed: 105 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8608 | 8608 |
| |
8609 | 8609 |
| |
8610 | 8610 |
| |
| 8611 | + | |
| 8612 | + | |
| 8613 | + | |
| 8614 | + | |
| 8615 | + | |
| 8616 | + | |
| 8617 | + | |
| 8618 | + | |
| 8619 | + | |
| 8620 | + | |
| 8621 | + | |
| 8622 | + | |
| 8623 | + | |
| 8624 | + | |
| 8625 | + | |
| 8626 | + | |
| 8627 | + | |
| 8628 | + | |
| 8629 | + | |
| 8630 | + | |
| 8631 | + | |
| 8632 | + | |
| 8633 | + | |
| 8634 | + | |
| 8635 | + | |
| 8636 | + | |
| 8637 | + | |
| 8638 | + | |
| 8639 | + | |
| 8640 | + | |
| 8641 | + | |
| 8642 | + | |
| 8643 | + | |
8611 | 8644 |
| |
8612 | 8645 |
| |
8613 | 8646 |
| |
| |||
8771 | 8804 |
| |
8772 | 8805 |
| |
8773 | 8806 |
| |
| 8807 | + | |
| 8808 | + | |
| 8809 | + | |
| 8810 | + | |
| 8811 | + | |
| 8812 | + | |
| 8813 | + | |
| 8814 | + | |
| 8815 | + | |
| 8816 | + | |
| 8817 | + | |
| 8818 | + | |
| 8819 | + | |
| 8820 | + | |
| 8821 | + | |
| 8822 | + | |
| 8823 | + | |
| 8824 | + | |
| 8825 | + | |
| 8826 | + | |
| 8827 | + | |
| 8828 | + | |
| 8829 | + | |
| 8830 | + | |
| 8831 | + | |
| 8832 | + | |
| 8833 | + | |
| 8834 | + | |
| 8835 | + | |
| 8836 | + | |
| 8837 | + | |
| 8838 | + | |
| 8839 | + | |
| 8840 | + | |
| 8841 | + | |
| 8842 | + | |
| 8843 | + | |
| 8844 | + | |
| 8845 | + | |
| 8846 | + | |
| 8847 | + | |
| 8848 | + | |
| 8849 | + | |
| 8850 | + | |
| 8851 | + | |
| 8852 | + | |
| 8853 | + | |
| 8854 | + | |
| 8855 | + | |
| 8856 | + | |
| 8857 | + | |
| 8858 | + | |
| 8859 | + | |
| 8860 | + | |
| 8861 | + | |
| 8862 | + | |
| 8863 | + | |
| 8864 | + | |
| 8865 | + | |
| 8866 | + | |
| 8867 | + | |
| 8868 | + | |
| 8869 | + | |
| 8870 | + | |
| 8871 | + | |
| 8872 | + | |
| 8873 | + | |
| 8874 | + | |
| 8875 | + | |
| 8876 | + | |
| 8877 | + | |
| 8878 | + | |
8774 | 8879 |
| |
8775 | 8880 |
| |
8776 | 8881 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2057 | 2057 |
| |
2058 | 2058 |
| |
2059 | 2059 |
| |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
2060 | 2069 |
| |
2061 | 2070 |
| |
2062 | 2071 |
| |
|
Lines changed: 102 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2373 | 2373 |
| |
2374 | 2374 |
| |
2375 | 2375 |
| |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
2376 | 2398 |
| |
2377 | 2399 |
| |
2378 | 2400 |
| |
| |||
2527 | 2549 |
| |
2528 | 2550 |
| |
2529 | 2551 |
| |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
2530 | 2632 |
| |
2531 | 2633 |
| |
2532 | 2634 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
665 | 665 |
| |
666 | 666 |
| |
667 | 667 |
| |
668 |
| - | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
669 | 671 |
| |
670 | 672 |
| |
671 | 673 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
398 | 398 |
| |
399 | 399 |
| |
400 | 400 |
| |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
401 | 405 |
| |
402 | 406 |
| |
403 | 407 |
| |
|
0 commit comments
Comments
(0)