v42-0005-Enhanced-Sorting-Efficiency-for-Integer-Lists.patch
text/x-patch
Filename: v42-0005-Enhanced-Sorting-Efficiency-for-Integer-Lists.patch
Type: text/x-patch
Part: 3
Patch
Format: format-patch
Series: patch v42-0005
Subject: Enhanced Sorting Efficiency for Integer Lists
| File | + | − |
|---|---|---|
| src/backend/parser/parse_agg.c | 1 | 2 |
From d36ac2636e639520f163475a7c08c0cf8b97b866 Mon Sep 17 00:00:00 2001 From: Stepan Neretin <sncfmgg@gmail.com> Date: Sat, 8 Jun 2024 00:32:44 +0700 Subject: [PATCH v42 5/6] Enhanced Sorting Efficiency for Integer Lists Refactored the sorting of lists containing integers in the `expand_grouping_sets` function within the `parse_agg.c` file. Replaced the generic sorting function with a custom optimized function tailored for integer types. This change leverages a custom sort template to enhance performance specifically for integer types. Details: - Updated the sorting of each groupset individually within the `expand_grouping_sets` function by replacing the loop-based `list_sort` with a single call to `list_int_sort`. - Updated the comparison function `list_int_cmp` to `int_cmp` within the `expand_grouping_sets` function. - Updated the `expand_grouping_sets` function to use `sort_list_ints` in two locations where sorting is performed. This refactor aims to improve sorting efficiency for integer lists in the context of expanding grouping sets within the `parse_agg.c` file, reducing processing time and enhancing overall system performance. --- src/backend/parser/parse_agg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index bee7d8346a..102131341a 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -1869,8 +1869,7 @@ expand_grouping_sets(List *groupingSets, bool groupDistinct, int limit) List *prev; /* Sort each groupset individually */ - foreach(cell, result) - list_sort(lfirst(cell), list_int_cmp); + list_int_sort(result); /* Now sort the list of groupsets by length and contents */ list_sort(result, cmp_list_len_contents_asc); -- 2.34.1