forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite0c91a7
committed
Improve some O(N^2) behavior in window function evaluation.
Repositioning the tuplestore seek pointer in window_gettupleslot() turnsout to be a very significant expense when the window frame is sizable andthe frame end can move. To fix, introduce a tuplestore function forskipping an arbitrary number of tuples in one call, parallel to the one weintroduced for tuplesort objects in commit8d65da1. This reduces the costof window_gettupleslot() to O(1) if the tuplestore has not spilled to disk.As in the previous commit, I didn't try to do any real optimization oftuplestore_skiptuples for the case where the tuplestore has spilled todisk. There is probably no practical way to get the cost to less than O(N)anyway, but perhaps someone can think of something later.Also fix PersistHoldablePortal() to make use of this API now that we haveit.Based on a suggestion by Dean Rasheed, though this turns out not to lookmuch like his patch.1 parent46a60ab commite0c91a7
File tree
4 files changed
+129
-32
lines changed- src
- backend
- commands
- executor
- utils/sort
- include/utils
4 files changed
+129
-32
lines changedLines changed: 11 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
389 | 389 |
| |
390 | 390 |
| |
391 | 391 |
| |
392 |
| - | |
393 |
| - | |
394 |
| - | |
395 |
| - | |
396 |
| - | |
397 |
| - | |
398 |
| - | |
| 392 | + | |
399 | 393 |
| |
400 | 394 |
| |
401 | 395 |
| |
402 | 396 |
| |
403 | 397 |
| |
404 |
| - | |
405 |
| - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
406 | 404 |
| |
407 | 405 |
| |
408 | 406 |
| |
409 | 407 |
| |
410 |
| - | |
411 |
| - | |
412 | 408 |
| |
413 | 409 |
| |
414 | 410 |
| |
415 | 411 |
| |
416 | 412 |
| |
417 | 413 |
| |
418 | 414 |
| |
419 |
| - | |
420 |
| - | |
421 |
| - | |
422 |
| - | |
423 |
| - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
424 | 419 |
| |
425 | 420 |
| |
426 | 421 |
| |
|
Lines changed: 43 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2371 | 2371 |
| |
2372 | 2372 |
| |
2373 | 2373 |
| |
2374 |
| - | |
2375 |
| - | |
2376 |
| - | |
2377 |
| - | |
| 2374 | + | |
2378 | 2375 |
| |
2379 |
| - | |
| 2376 | + | |
2380 | 2377 |
| |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
2381 | 2401 |
| |
2382 | 2402 |
| |
2383 | 2403 |
| |
2384 | 2404 |
| |
2385 |
| - | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
2386 | 2410 |
| |
2387 | 2411 |
| |
2388 | 2412 |
| |
2389 | 2413 |
| |
2390 | 2414 |
| |
2391 |
| - | |
2392 |
| - | |
| 2415 | + | |
2393 | 2416 |
| |
2394 | 2417 |
| |
2395 | 2418 |
| |
2396 | 2419 |
| |
2397 | 2420 |
| |
2398 | 2421 |
| |
| 2422 | + | |
| 2423 | + | |
2399 | 2424 |
| |
2400 | 2425 |
| |
2401 | 2426 |
| |
| |||
2478 | 2503 |
| |
2479 | 2504 |
| |
2480 | 2505 |
| |
2481 |
| - | |
| 2506 | + | |
2482 | 2507 |
| |
2483 |
| - | |
2484 |
| - | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
2485 | 2512 |
| |
2486 | 2513 |
| |
2487 |
| - | |
| 2514 | + | |
2488 | 2515 |
| |
2489 |
| - | |
2490 |
| - | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
2491 | 2520 |
| |
2492 | 2521 |
| |
2493 | 2522 |
| |
|
Lines changed: 71 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
| 60 | + | |
60 | 61 |
| |
61 | 62 |
| |
62 | 63 |
| |
| |||
1065 | 1066 |
| |
1066 | 1067 |
| |
1067 | 1068 |
| |
1068 |
| - | |
1069 |
| - | |
| 1069 | + | |
1070 | 1070 |
| |
1071 | 1071 |
| |
1072 | 1072 |
| |
| |||
1088 | 1088 |
| |
1089 | 1089 |
| |
1090 | 1090 |
| |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
1091 | 1160 |
| |
1092 | 1161 |
| |
1093 | 1162 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
| 75 | + | |
75 | 76 |
| |
76 | 77 |
| |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 |
| |
78 | 82 |
| |
79 | 83 |
| |
|
0 commit comments
Comments
(0)