Some clean-up work in get_cheapest_group_keys_order()

Поиск
Список
Период
Сортировка
От David Rowley
Тема Some clean-up work in get_cheapest_group_keys_order()
Дата
Msg-id CAApHDvrGyL3ft8waEkncG9y5HDMu5TFFJB1paoTC8zi9YK97Nw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Some clean-up work in get_cheapest_group_keys_order()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Extending outfuncs support to utility statements
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Some clean-up work in get_cheapest_group_keys_order()