forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf7816ae
committed
Extract column statistics from CTE references, if possible.
examine_simple_variable() left this as an unimplemented case yearsago, with the result that plans for queries involving un-flattenedCTEs might be much stupider than necessary. It's not hard to extendthe existing logic for RTE_SUBQUERY cases to also be able to drilldown into CTEs, so let's do that.There was some discussion of whether this patch breaks the ideaof a MATERIALIZED CTE being an optimization fence. We concludedit's okay, because we already allow the outer planner level tosee the estimated width and rowcount of the CTE result, andletting it see column statistics too seems fairly equivalent.Basically, what we expect of the optimization fence is that theouter query should not affect the plan chosen for the CTE query.Once that plan is chosen, it's okay for the outer planner levelto make use of whatever information we have about it.Jian Guo and Tom Lane, per complaint from Hans BuschmannDiscussion:https://postgr.es/m/4504e67078d648cdac3651b2960da6e7@nidsa.net1 parent06c7084 commitf7816ae
File tree
3 files changed
+124
-35
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+124
-35
lines changedLines changed: 99 additions & 35 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5363 | 5363 |
| |
5364 | 5364 |
| |
5365 | 5365 |
| |
5366 |
| - | |
| 5366 | + | |
5367 | 5367 |
| |
5368 | 5368 |
| |
5369 | 5369 |
| |
| |||
5497 | 5497 |
| |
5498 | 5498 |
| |
5499 | 5499 |
| |
5500 |
| - | |
| 5500 | + | |
| 5501 | + | |
5501 | 5502 |
| |
5502 | 5503 |
| |
5503 |
| - | |
| 5504 | + | |
| 5505 | + | |
| 5506 | + | |
| 5507 | + | |
| 5508 | + | |
5504 | 5509 |
| |
5505 |
| - | |
5506 |
| - | |
| 5510 | + | |
| 5511 | + | |
| 5512 | + | |
5507 | 5513 |
| |
5508 | 5514 |
| |
5509 | 5515 |
| |
| |||
5512 | 5518 |
| |
5513 | 5519 |
| |
5514 | 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 | + | |
| 5591 | + | |
| 5592 | + | |
| 5593 | + | |
| 5594 | + | |
| 5595 | + | |
| 5596 | + | |
| 5597 | + | |
| 5598 | + | |
| 5599 | + | |
5515 | 5600 |
| |
5516 | 5601 |
| |
5517 | 5602 |
| |
| |||
5525 | 5610 |
| |
5526 | 5611 |
| |
5527 | 5612 |
| |
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 | 5613 |
| |
5554 |
| - | |
| 5614 | + | |
| 5615 | + | |
| 5616 | + | |
| 5617 | + | |
| 5618 | + | |
5555 | 5619 |
| |
5556 | 5620 |
| |
5557 | 5621 |
| |
| |||
5599 | 5663 |
| |
5600 | 5664 |
| |
5601 | 5665 |
| |
5602 |
| - | |
| 5666 | + | |
5603 | 5667 |
| |
5604 | 5668 |
| |
5605 | 5669 |
| |
5606 | 5670 |
| |
5607 | 5671 |
| |
5608 |
| - | |
5609 |
| - | |
| 5672 | + | |
| 5673 | + | |
5610 | 5674 |
| |
5611 |
| - | |
| 5675 | + | |
5612 | 5676 |
| |
5613 | 5677 |
| |
5614 | 5678 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
636 | 636 |
| |
637 | 637 |
| |
638 | 638 |
| |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
639 | 657 |
| |
640 | 658 |
| |
641 | 659 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
347 | 347 |
| |
348 | 348 |
| |
349 | 349 |
| |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
350 | 357 |
| |
351 | 358 |
| |
352 | 359 |
| |
|
0 commit comments
Comments
(0)