- Notifications
You must be signed in to change notification settings - Fork5
Commit34d4f49
committed
Speed up ruleutils' name de-duplication code, and fix overlength-name case.
Since commit11e1318, ruleutils.c hasattempted to ensure that each RTE in a query or plan tree has a uniquealias name. However, the code that was added for this could be quite slow,even as bad as O(N^3) if N identical RTE names must be replaced, as notedby Jeff Janes. Improve matters by building a transient hash table withinset_rtable_names. The hash table in itself reduces the cost of detecting aduplicate from O(N) to O(1), and we can save another factor of N by storingthe number of de-duplicated names already created for each entry, so thatwe don't have to re-try names already created. This way is probably a bitslower overall for small range tables, but almost by definition, such casesshould not be a performance problem.In principle the same problem applies to the column-name-de-duplicationcode; but in practice that seems to be less of a problem, first becauseN is limited since we don't support extremely wide tables, and secondbecause duplicate column names within an RTE are fairly rare, so that inpractice the cost is more like O(N^2) not O(N^3). It would be very muchmessier to fix the column-name code, so for now I've left that alone.An independent problem in the same area was that the de-duplication codepaid no attention to the identifier length limit, and would happily produceidentifiers that were longer than NAMEDATALEN and wouldn't be unique aftertruncation to NAMEDATALEN. This could result in dump/reload failures, orperhaps even views that silently behaved differently than before. We canfix that by shortening the base name as needed. Fix it for both therelation and column name cases.In passing, check for interrupts in set_rtable_names, just in case it'sstill slow enough to be an issue.Back-patch to 9.3 where this code was introduced.1 parent0489a04 commit34d4f49
File tree
3 files changed
+161
-46
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+161
-46
lines changedLines changed: 125 additions & 46 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
| 41 | + | |
41 | 42 |
| |
42 | 43 |
| |
43 | 44 |
| |
| |||
55 | 56 |
| |
56 | 57 |
| |
57 | 58 |
| |
| 59 | + | |
58 | 60 |
| |
59 | 61 |
| |
60 | 62 |
| |
| |||
267 | 269 |
| |
268 | 270 |
| |
269 | 271 |
| |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
270 | 281 |
| |
271 | 282 |
| |
272 | 283 |
| |
| |||
312 | 323 |
| |
313 | 324 |
| |
314 | 325 |
| |
315 |
| - | |
316 |
| - | |
317 | 326 |
| |
318 | 327 |
| |
319 | 328 |
| |
| |||
2676 | 2685 |
| |
2677 | 2686 |
| |
2678 | 2687 |
| |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
2679 | 2693 |
| |
2680 |
| - | |
2681 | 2694 |
| |
2682 | 2695 |
| |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
2683 | 2735 |
| |
2684 | 2736 |
| |
2685 | 2737 |
| |
2686 | 2738 |
| |
2687 | 2739 |
| |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
2688 | 2743 |
| |
2689 | 2744 |
| |
2690 | 2745 |
| |
| |||
2712 | 2767 |
| |
2713 | 2768 |
| |
2714 | 2769 |
| |
2715 |
| - | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
2716 | 2774 |
| |
2717 |
| - | |
2718 |
| - | |
| 2775 | + | |
2719 | 2776 |
| |
2720 |
| - | |
2721 |
| - | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
2722 | 2787 |
| |
2723 |
| - | |
| 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 | + | |
2724 | 2815 |
| |
2725 |
| - | |
2726 |
| - | |
2727 |
| - | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
2728 | 2819 |
| |
2729 | 2820 |
| |
2730 | 2821 |
| |
2731 | 2822 |
| |
2732 | 2823 |
| |
2733 |
| - | |
2734 |
| - | |
2735 |
| - | |
2736 |
| - | |
2737 |
| - | |
2738 |
| - | |
2739 |
| - | |
2740 |
| - | |
2741 |
| - | |
2742 |
| - | |
2743 | 2824 |
| |
2744 |
| - | |
2745 |
| - | |
2746 |
| - | |
2747 |
| - | |
2748 |
| - | |
2749 |
| - | |
2750 |
| - | |
2751 |
| - | |
2752 |
| - | |
2753 |
| - | |
2754 |
| - | |
2755 |
| - | |
2756 |
| - | |
2757 |
| - | |
2758 |
| - | |
2759 |
| - | |
2760 |
| - | |
2761 |
| - | |
2762 |
| - | |
2763 |
| - | |
2764 |
| - | |
| 2825 | + | |
2765 | 2826 |
| |
2766 | 2827 |
| |
2767 | 2828 |
| |
| |||
3589 | 3650 |
| |
3590 | 3651 |
| |
3591 | 3652 |
| |
3592 |
| - | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
3593 | 3656 |
| |
3594 | 3657 |
| |
3595 | 3658 |
| |
3596 |
| - | |
| 3659 | + | |
| 3660 | + | |
3597 | 3661 |
| |
3598 | 3662 |
| |
3599 | 3663 |
| |
3600 | 3664 |
| |
3601 |
| - | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
3602 | 3681 |
| |
3603 | 3682 |
| |
3604 | 3683 |
| |
|
Lines changed: 27 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1475 | 1475 |
| |
1476 | 1476 |
| |
1477 | 1477 |
| |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
1478 | 1505 |
| |
1479 | 1506 |
| |
1480 | 1507 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
487 | 487 |
| |
488 | 488 |
| |
489 | 489 |
| |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
490 | 499 |
| |
491 | 500 |
| |
492 | 501 |
| |
|
0 commit comments
Comments
(0)