Some clean-up work in get_cheapest_group_keys_order() - Mailing list pgsql-hackers

From David Rowley
Subject Some clean-up work in get_cheapest_group_keys_order()
Date
Msg-id CAApHDvrGyL3ft8waEkncG9y5HDMu5TFFJB1paoTC8zi9YK97Nw@mail.gmail.com
Whole thread Raw
Responses Re: Some clean-up work in get_cheapest_group_keys_order()
List pgsql-hackers
I was rebasing a patch which requires me to make some changes in
get_cheapest_group_keys_order().  I noticed a few things in there that
I think we could do a little better on:

* The code uses pfree() on a list and it should be using list_free()

* There's a manually coded for loop over a list which seems to be done
so we can skip the first n elements of the list.  for_each_from()
should be used for that.

* I think list_truncate(list_copy(list), n) is a pretty bad way to
copy the first n elements of a list, especially when n is likely to be
0 most of the time. I think we should just add a function called
list_copy_head(). We already have list_copy_tail().

* We could reduce some of the branching in the while loop and just set
cheapest_sort_cost to DBL_MAX to save having to check if we're doing
the first loop.

I think the first 3 are worth fixing in PG15 since all that code is
new to that version. The 4th, I'm so sure about.

Does anyone else have any thoughts?

David

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Extending outfuncs support to utility statements
Next
From: Tom Lane
Date:
Subject: Re: Some clean-up work in get_cheapest_group_keys_order()