forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commited1a88d
committed
Allow window functions to adjust their frameOptions
WindowFuncs such as row_number() don't care if it's called with ROWSUNBOUNDED PRECEDING AND CURRENT ROW or with RANGE UNBOUNDED PRECEDING ANDCURRENT ROW. The latter is less efficient as the RANGE option requiresthat the executor check for peer rows, so using the ROW option insteadwould cause less overhead. Because RANGE is part of the default frameoptions for WindowClauses, it means WindowAgg is, by default, working muchharder than it needs to for window functions where the ROWS / RANGE optionhas no effect on the window function's result.On a test query from the discussion thread, a performance improvement of344% was seen by using ROWS instead of RANGE.Here we add a new support function node type to allow support functions tobe called for window functions so that the most optimal version of theframe options can be set. The planner has been adjusted so that the frameoptions are changed only if all window functions sharing the same windowclause agree on what the optimized frame options are.Here we give the ability for row_number(), rank(), dense_rank(),percent_rank(), cume_dist() and ntile() to alter their WindowClause'sframeOptions.Reviewed-by: Vik Fearing, Erwin Brandstetter, Zhihong YuDiscussion:https://postgr.es/m/CAGHENJ7LBBszxS+SkWWFVnBmOT2oVsBhDMB1DFrgerCeYa_DyA@mail.gmail.comDiscussion:https://postgr.es/m/CAApHDvohAKEtTXxq7Pc-ic2dKT8oZfbRKeEJP64M0B6+S88z+A@mail.gmail.com1 parentcc15059 commited1a88d
File tree
8 files changed
+480
-4
lines changed- src
- backend
- optimizer/plan
- parser
- utils/adt
- include
- catalog
- nodes
- test/regress
- expected
- sql
8 files changed
+480
-4
lines changedLines changed: 156 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
| 44 | + | |
44 | 45 |
| |
45 | 46 |
| |
46 | 47 |
| |
| |||
208 | 209 |
| |
209 | 210 |
| |
210 | 211 |
| |
| 212 | + | |
| 213 | + | |
211 | 214 |
| |
212 | 215 |
| |
213 | 216 |
| |
| |||
1430 | 1433 |
| |
1431 | 1434 |
| |
1432 | 1435 |
| |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
1433 | 1444 |
| |
| 1445 | + | |
1434 | 1446 |
| |
1435 | 1447 |
| |
1436 | 1448 |
| |
| |||
5432 | 5444 |
| |
5433 | 5445 |
| |
5434 | 5446 |
| |
| 5447 | + | |
| 5448 | + | |
| 5449 | + | |
| 5450 | + | |
| 5451 | + | |
| 5452 | + | |
| 5453 | + | |
| 5454 | + | |
| 5455 | + | |
| 5456 | + | |
| 5457 | + | |
| 5458 | + | |
| 5459 | + | |
| 5460 | + | |
| 5461 | + | |
| 5462 | + | |
| 5463 | + | |
| 5464 | + | |
| 5465 | + | |
| 5466 | + | |
| 5467 | + | |
| 5468 | + | |
| 5469 | + | |
| 5470 | + | |
| 5471 | + | |
| 5472 | + | |
| 5473 | + | |
| 5474 | + | |
| 5475 | + | |
| 5476 | + | |
| 5477 | + | |
| 5478 | + | |
| 5479 | + | |
| 5480 | + | |
| 5481 | + | |
| 5482 | + | |
| 5483 | + | |
| 5484 | + | |
| 5485 | + | |
| 5486 | + | |
| 5487 | + | |
| 5488 | + | |
| 5489 | + | |
| 5490 | + | |
| 5491 | + | |
| 5492 | + | |
| 5493 | + | |
| 5494 | + | |
| 5495 | + | |
| 5496 | + | |
| 5497 | + | |
| 5498 | + | |
| 5499 | + | |
| 5500 | + | |
| 5501 | + | |
| 5502 | + | |
| 5503 | + | |
| 5504 | + | |
| 5505 | + | |
| 5506 | + | |
| 5507 | + | |
| 5508 | + | |
| 5509 | + | |
| 5510 | + | |
| 5511 | + | |
| 5512 | + | |
| 5513 | + | |
| 5514 | + | |
| 5515 | + | |
| 5516 | + | |
| 5517 | + | |
| 5518 | + | |
| 5519 | + | |
| 5520 | + | |
| 5521 | + | |
| 5522 | + | |
| 5523 | + | |
| 5524 | + | |
| 5525 | + | |
| 5526 | + | |
| 5527 | + | |
| 5528 | + | |
| 5529 | + | |
| 5530 | + | |
| 5531 | + | |
| 5532 | + | |
| 5533 | + | |
| 5534 | + | |
| 5535 | + | |
| 5536 | + | |
| 5537 | + | |
| 5538 | + | |
| 5539 | + | |
| 5540 | + | |
| 5541 | + | |
| 5542 | + | |
| 5543 | + | |
| 5544 | + | |
| 5545 | + | |
| 5546 | + | |
| 5547 | + | |
| 5548 | + | |
| 5549 | + | |
| 5550 | + | |
| 5551 | + | |
| 5552 | + | |
| 5553 | + | |
| 5554 | + | |
| 5555 | + | |
| 5556 | + | |
| 5557 | + | |
| 5558 | + | |
| 5559 | + | |
| 5560 | + | |
| 5561 | + | |
| 5562 | + | |
| 5563 | + | |
| 5564 | + | |
| 5565 | + | |
| 5566 | + | |
| 5567 | + | |
| 5568 | + | |
| 5569 | + | |
| 5570 | + | |
| 5571 | + | |
| 5572 | + | |
| 5573 | + | |
| 5574 | + | |
| 5575 | + | |
| 5576 | + | |
| 5577 | + | |
| 5578 | + | |
| 5579 | + | |
| 5580 | + | |
| 5581 | + | |
| 5582 | + | |
| 5583 | + | |
| 5584 | + | |
| 5585 | + | |
| 5586 | + | |
| 5587 | + | |
| 5588 | + | |
| 5589 | + | |
| 5590 | + | |
5435 | 5591 |
| |
5436 | 5592 |
| |
5437 | 5593 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1025 | 1025 |
| |
1026 | 1026 |
| |
1027 | 1027 |
| |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
1028 | 1032 |
| |
1029 | 1033 |
| |
1030 | 1034 |
| |
|
Lines changed: 148 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
110 | 128 |
| |
111 | 129 |
| |
112 | 130 |
| |
| |||
149 | 167 |
| |
150 | 168 |
| |
151 | 169 |
| |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
152 | 191 |
| |
153 | 192 |
| |
154 | 193 |
| |
| |||
190 | 229 |
| |
191 | 230 |
| |
192 | 231 |
| |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
193 | 250 |
| |
194 | 251 |
| |
195 | 252 |
| |
| |||
222 | 279 |
| |
223 | 280 |
| |
224 | 281 |
| |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
225 | 313 |
| |
226 | 314 |
| |
227 | 315 |
| |
| |||
265 | 353 |
| |
266 | 354 |
| |
267 | 355 |
| |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
268 | 386 |
| |
269 | 387 |
| |
270 | 388 |
| |
| |||
338 | 456 |
| |
339 | 457 |
| |
340 | 458 |
| |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
341 | 489 |
| |
342 | 490 |
| |
343 | 491 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
60 |
| - | |
| 60 | + | |
61 | 61 |
| |
62 | 62 |
|
0 commit comments
Comments
(0)