Re: POC: converting Lists into arrays

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: POC: converting Lists into arrays
Date: 2019-07-17 14:12:28
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> On 17 Jul 2019, at 01:06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> There are a bunch of places that are using list_delete_first to remove
> the next-to-process entry from a List used as a queue. In principle,
> we could invert the order of those queues and then use list_delete_last,
> but I thought this would probably be too confusing: it's natural to
> think of the front of the list as being the head of the queue. I doubt
> that any of those queues get long enough for it to be a serious
> performance problem to leave them as-is.

For cases where an Oid list is copied and then head elements immediately
removed, as in fetch_search_path, couldn’t we instead use a counter and
list_copy_tail to avoid repeated list_delete_first calls? Something like the
attached poc.

> +List *
> +list_delete_last(List *list)
> +{
> + check_list_invariants(list);
> +
> + if (list == NIL)
> + return NIL; /* would an error be better? */

Since we’ve allowed list_delete_first on NIL for a long time, it seems
reasonable to do the same for list_delete_last even though it’s hard to come up
with a good usecase for deleting the last element without inspecting the list
(a stack growing from the bottom perhaps?). It reads better to check for NIL
before calling check_list_invariants though IMO.

Looking mainly at 0001 for now, I agree that the order is insignificant.

cheers ./daniel

Attachment Content-Type Size
fetch_search_path_listcopy.diff application/octet-stream 965 bytes

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-07-17 14:16:18 Re: POC: converting Lists into arrays
Previous Message Ibrar Ahmed 2019-07-17 14:08:07 Re: block-level incremental backup