forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit05c8482
Amit Kapila
Enable parallel SELECT for "INSERT INTO ... SELECT ...".
Parallel SELECT can't be utilized for INSERT in the following cases:- INSERT statement uses the ON CONFLICT DO UPDATE clause- Target table has a parallel-unsafe: trigger, index expression or predicate, column default expression or check constraint- Target table has a parallel-unsafe domain constraint on any column- Target table is a partitioned table with a parallel-unsafe partition key expression or support functionThe planner is updated to perform additional parallel-safety checks forthe cases listed above, for determining whether it is safe to run INSERTin parallel-mode with an underlying parallel SELECT. The planner willconsider using parallel SELECT for "INSERT INTO ... SELECT ...", providednothing unsafe is found from the additional parallel-safety checks, orfrom the existing parallel-safety checks for SELECT.While checking parallel-safety, we need to check it for all the partitionson the table which can be costly especially when we decide not to use aparallel plan. So, in a separate patch, we will introduce a GUC and or areloption to enable/disable parallelism for Insert statements.Prior to entering parallel-mode for the execution of INSERT with parallelSELECT, a TransactionId is acquired and assigned to the currenttransaction state. This is necessary to prevent the INSERT from attemptingto assign the TransactionId whilst in parallel-mode, which is not allowed.This approach has a disadvantage in that if the underlying SELECT does notreturn any rows, then the TransactionId is not used, however thatshouldn't happen in practice in many cases.Author: Greg Nancarrow, Amit Langote, Amit KapilaReviewed-by: Amit Langote, Hou Zhijie, Takayuki Tsunakawa, Antonin Houska, Bharath Rupireddy, Dilip Kumar, Vignesh C, Zhihong Yu, Amit KapilaTested-by: Tang, HaiyingDiscussion:https://postgr.es/m/CAJcOf-cXnB5cnMKqWEp2E2z7Mvcd04iLVmV=qpFJrR3AcrTS3g@mail.gmail.comDiscussion:https://postgr.es/m/CAJcOf-fAdj=nDKMsRhQzndm-O13NY4dL6xGcEvdX5Xvbbi0V7g@mail.gmail.com1 parent0ba7110 commit05c8482
File tree
17 files changed
+1531
-21
lines changed- doc/src/sgml
- src
- backend
- access/transam
- executor
- nodes
- optimizer
- plan
- util
- utils/cache
- include
- access
- nodes
- optimizer
- test/regress
- expected
- sql
17 files changed
+1531
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
1017 | 1043 | | |
1018 | 1044 | | |
1019 | 1045 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1512 | 1512 | | |
1513 | 1513 | | |
1514 | 1514 | | |
| 1515 | + | |
| 1516 | + | |
1515 | 1517 | | |
| 1518 | + | |
1516 | 1519 | | |
1517 | 1520 | | |
1518 | 1521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| 317 | + | |
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| |||
2221 | 2222 | | |
2222 | 2223 | | |
2223 | 2224 | | |
| 2225 | + | |
2224 | 2226 | | |
2225 | 2227 | | |
2226 | 2228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1590 | 1590 | | |
1591 | 1591 | | |
1592 | 1592 | | |
| 1593 | + | |
1593 | 1594 | | |
1594 | 1595 | | |
1595 | 1596 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
| |||
316 | 317 | | |
317 | 318 | | |
318 | 319 | | |
319 | | - | |
320 | | - | |
321 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
322 | 323 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
| |||
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
337 | | - | |
| 338 | + | |
| 339 | + | |
338 | 340 | | |
339 | 341 | | |
340 | 342 | | |
341 | 343 | | |
342 | 344 | | |
343 | | - | |
| 345 | + | |
344 | 346 | | |
345 | 347 | | |
346 | 348 | | |
| |||
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
524 | 539 | | |
525 | 540 | | |
526 | 541 | | |
| |||
0 commit comments
Comments
(0)