From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> |
Subject: | Some clean-up work in get_cheapest_group_keys_order() |
Date: | 2022-07-12 22:55:07 |
Message-ID: | CAApHDvrGyL3ft8waEkncG9y5HDMu5TFFJB1paoTC8zi9YK97Nw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
cleanup_get_cheapest_group_keys_order.patch | text/plain | 3.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-07-12 23:02:02 | Re: Some clean-up work in get_cheapest_group_keys_order() |
Previous Message | Tom Lane | 2022-07-12 22:38:26 | Re: Extending outfuncs support to utility statements |