Re: A tidyup of pathkeys.c

Chao Li <li.evan.chao@gmail.com>

From: Chao Li <li.evan.chao@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2025-10-14T23:49:08Z
Lists: pgsql-hackers

> On Oct 14, 2025, at 19:22, David Rowley <dgrowleyml@gmail.com> wrote:
> 
> What makes you think making them inline would make the performance the
> same as before? The previous functions were not inlined, and I've not
> made any changes that should affect the compiler's ability to choose
> to inline these functions or not.


Ah… You are right. The old code:

static int
pathkeys_useful_for_ordering(PlannerInfo *root, List *pathkeys)
{
    int         n_common_pathkeys;

    (void) pathkeys_count_contained_in(root->sort_pathkeys, pathkeys,
                                       &n_common_pathkeys);

    return n_common_pathkeys;
}

Your patch’s code:

static int
count_common_leading_pathkeys_ordered(List *keys1, List *keys2)
{
    int         ncommon;

    (void) pathkeys_count_contained_in(keys1, keys2, &ncommon);

    return ncommon;
}

They both call pathkeys_count_contained_in(), you are NOT adding an extra wrapper. So, I withdraw the “inline” comment.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/




Commits

  1. Tidyup truncate_useless_pathkeys() function