Re: Cleaning up nbtree after logical decoding on standby work

Peter Geoghegan <pg@bowt.ie>

From: Peter Geoghegan <pg@bowt.ie>
To: Andres Freund <andres@anarazel.de>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Heikki Linnakangas <hlinnaka@iki.fi>, Michael Paquier <michael@paquier.xyz>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>
Date: 2023-06-10T21:10:26Z
Lists: pgsql-hackers
On Fri, Jun 9, 2023 at 12:23 PM Peter Geoghegan <pg@bowt.ie> wrote:
> > I'm not sure there is that concensus (for me half the changes shouldn't be
> > done, the rest should be in 17), but in the end it doesn't matter that much.

I pushed this just now. I have also closed out the open item.

> > > --- a/src/include/utils/tuplesort.h
> > > +++ b/src/include/utils/tuplesort.h
> > > @@ -399,9 +399,7 @@ extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc,
> > >                                                                                       int workMem, SortCoordinate coordinate,
> > >                                                                                       int sortopt);
> > >  extern Tuplesortstate *tuplesort_begin_cluster(TupleDesc tupDesc,
> > > -                                                                                        Relation indexRel,
> > > -                                                                                        Relation heaprel,
> > > -                                                                                        int workMem,
> > > +                                                                                        Relation indexRel, int workMem,
> > >                                                                                          SortCoordinate coordinate,
> > >                                                                                          int sortopt);
> >
> > I think we should continue to provide the table here, even if we don't need it
> > today.
>
> I don't see why, but okay. I'll do it that way.

I didn't end up doing that in the version that I pushed (heaprel was
removed from tuplesort_begin_cluster in the final version after all),
since I couldn't justify the use of NewHeap over OldHeap at the call
site in heapam_handler.c. If you're interested in following up with
this yourself, I have no objections.

--
Peter Geoghegan



Commits

  1. nbtree: Allocate new pages in separate function.

  2. Pass down table relation into more index relation functions

  3. Note case where nbtree VACUUM finishes splits.

  4. Fix interaction between CREATE INDEX and "snapshot too old".