- Notifications
You must be signed in to change notification settings - Fork5k
Commit430a595
committed
Defer remove_useless_groupby_columns() work until query_planner()
Traditionally, remove_useless_groupby_columns() was called duringgrouping_planner() directly after the call to preprocess_groupclause().While in many ways, it made sense to populate the field and remove thefunctionally dependent columns from processed_groupClause at the sametime, it's just that doing so had the disadvantage thatremove_useless_groupby_columns() was being called before the RelOptInfoswere populated for the relations mentioned in the query. Not havingRelOptInfos available meant we needed to manually query the catalog tablesto get the required details about the primary key constraint for thetable.Here we move the remove_useless_groupby_columns() call toquery_planner() and put it directly after the RelOptInfos are populated.This is fine to do as processed_groupClause still isn't final at thispoint as it can still be modified inside standard_qp_callback() bymake_pathkeys_for_sortclauses_extended().This commit is just a refactor and simply movesremove_useless_groupby_columns() into initsplan.c. A planned follow-upcommit will adjust that function so it uses RelOptInfo instead of doingcatalog lookups and also teach it how to use unique indexes as proofs toexpand the cases where we can remove functionally dependent columns fromthe GROUP BY.Reviewed-by: Andrei Lepikhov, jian heDiscussion:https://postgr.es/m/CAApHDvqLezKwoEBBQd0dp4Y9MDkFBDbny0f3SzEeqOFoU7Z5+A@mail.gmail.com1 parent78c5e14 commit430a595
File tree
4 files changed
+170
-165
lines changed- src
- backend/optimizer/plan
- include/optimizer
4 files changed
+170
-165
lines changedLines changed: 166 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 |
| - | |
| 4 | + | |
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
| 17 | + | |
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
| |||
386 | 387 |
| |
387 | 388 |
| |
388 | 389 |
| |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 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 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
389 | 554 |
| |
390 | 555 |
| |
391 | 556 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
169 | 169 |
| |
170 | 170 |
| |
171 | 171 |
| |
| 172 | + | |
| 173 | + | |
| 174 | + | |
172 | 175 |
| |
173 | 176 |
| |
174 | 177 |
| |
|
Lines changed: 0 additions & 164 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
27 | 26 |
| |
28 | 27 |
| |
29 | 28 |
| |
| |||
139 | 138 |
| |
140 | 139 |
| |
141 | 140 |
| |
142 |
| - | |
143 | 141 |
| |
144 | 142 |
| |
145 | 143 |
| |
| |||
1487 | 1485 |
| |
1488 | 1486 |
| |
1489 | 1487 |
| |
1490 |
| - | |
1491 |
| - | |
1492 | 1488 |
| |
1493 | 1489 |
| |
1494 | 1490 |
| |
| |||
2724 | 2720 |
| |
2725 | 2721 |
| |
2726 | 2722 |
| |
2727 |
| - | |
2728 |
| - | |
2729 |
| - | |
2730 |
| - | |
2731 |
| - | |
2732 |
| - | |
2733 |
| - | |
2734 |
| - | |
2735 |
| - | |
2736 |
| - | |
2737 |
| - | |
2738 |
| - | |
2739 |
| - | |
2740 |
| - | |
2741 |
| - | |
2742 |
| - | |
2743 |
| - | |
2744 |
| - | |
2745 |
| - | |
2746 |
| - | |
2747 |
| - | |
2748 |
| - | |
2749 |
| - | |
2750 |
| - | |
2751 |
| - | |
2752 |
| - | |
2753 |
| - | |
2754 |
| - | |
2755 |
| - | |
2756 |
| - | |
2757 |
| - | |
2758 |
| - | |
2759 |
| - | |
2760 |
| - | |
2761 |
| - | |
2762 |
| - | |
2763 |
| - | |
2764 |
| - | |
2765 |
| - | |
2766 |
| - | |
2767 |
| - | |
2768 |
| - | |
2769 |
| - | |
2770 |
| - | |
2771 |
| - | |
2772 |
| - | |
2773 |
| - | |
2774 |
| - | |
2775 |
| - | |
2776 |
| - | |
2777 |
| - | |
2778 |
| - | |
2779 |
| - | |
2780 |
| - | |
2781 |
| - | |
2782 |
| - | |
2783 |
| - | |
2784 |
| - | |
2785 |
| - | |
2786 |
| - | |
2787 |
| - | |
2788 |
| - | |
2789 |
| - | |
2790 |
| - | |
2791 |
| - | |
2792 |
| - | |
2793 |
| - | |
2794 |
| - | |
2795 |
| - | |
2796 |
| - | |
2797 |
| - | |
2798 |
| - | |
2799 |
| - | |
2800 |
| - | |
2801 |
| - | |
2802 |
| - | |
2803 |
| - | |
2804 |
| - | |
2805 |
| - | |
2806 |
| - | |
2807 |
| - | |
2808 |
| - | |
2809 |
| - | |
2810 |
| - | |
2811 |
| - | |
2812 |
| - | |
2813 |
| - | |
2814 |
| - | |
2815 |
| - | |
2816 |
| - | |
2817 |
| - | |
2818 |
| - | |
2819 |
| - | |
2820 |
| - | |
2821 |
| - | |
2822 |
| - | |
2823 |
| - | |
2824 |
| - | |
2825 |
| - | |
2826 |
| - | |
2827 |
| - | |
2828 |
| - | |
2829 |
| - | |
2830 |
| - | |
2831 |
| - | |
2832 |
| - | |
2833 |
| - | |
2834 |
| - | |
2835 |
| - | |
2836 |
| - | |
2837 |
| - | |
2838 |
| - | |
2839 |
| - | |
2840 |
| - | |
2841 |
| - | |
2842 |
| - | |
2843 |
| - | |
2844 |
| - | |
2845 |
| - | |
2846 |
| - | |
2847 |
| - | |
2848 |
| - | |
2849 |
| - | |
2850 |
| - | |
2851 |
| - | |
2852 |
| - | |
2853 |
| - | |
2854 |
| - | |
2855 |
| - | |
2856 |
| - | |
2857 |
| - | |
2858 |
| - | |
2859 |
| - | |
2860 |
| - | |
2861 |
| - | |
2862 |
| - | |
2863 |
| - | |
2864 |
| - | |
2865 |
| - | |
2866 |
| - | |
2867 |
| - | |
2868 |
| - | |
2869 |
| - | |
2870 |
| - | |
2871 |
| - | |
2872 |
| - | |
2873 |
| - | |
2874 |
| - | |
2875 |
| - | |
2876 |
| - | |
2877 |
| - | |
2878 |
| - | |
2879 |
| - | |
2880 |
| - | |
2881 |
| - | |
2882 |
| - | |
2883 |
| - | |
2884 |
| - | |
2885 |
| - | |
2886 |
| - | |
2887 | 2723 |
| |
2888 | 2724 |
| |
2889 | 2725 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
| 77 | + | |
77 | 78 |
| |
78 | 79 |
| |
79 | 80 |
| |
|
0 commit comments
Comments
(0)