Re: Tid scan improvements
От | David Rowley |
---|---|
Тема | Re: Tid scan improvements |
Дата | |
Msg-id | CAApHDvqoO33Em0tWoJvwN2cqvAJ45nB+qqfS5cxLbQ45BGPwkg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Tid scan improvements (David Rowley <dgrowleyml@gmail.com>) |
Список | pgsql-hackers |
On Thu, 18 Feb 2021 at 09:45, David Rowley <dgrowleyml@gmail.com> wrote: > > On Wed, 17 Feb 2021 at 11:05, Andres Freund <andres@anarazel.de> wrote: > > Architecturally it feels like this is something that really belongs more > > into plan time? > > Possibly. It would mean TidOpExpr would have to become a Node type. > TID Range scan is really just following the lead set by TID Scan here. > > I'm not sure if it's worth the trouble making these Node types for the > small gains there'd be in the performance of having the planner make > them once for prepared queries rather than them having to be built > during each execution. I changed the code around and added a new Node type to the planner and made it create the TidRangeExpr during planning. However, I'm pretty much set on this being pretty horrible and I ended up ripping it back out again. The reason is that there's quite a bit of extra boilerplate code that goes with the new node type. e.g it must be handled in setrefs.c. EXPLAIN also needs to know about the new Node. That either means teaching the deparse code about TidRangeExprs or having the Plan node carry along the OpExprs just so we can make EXPLAIN work. Translating between the two might be possible but it just seemed too much code and I started feeling pretty bad about the whole idea. > > > +/* > > > + * table_set_tidrange resets the minimum and maximum TID range to scan for a > > > + * TableScanDesc created by table_beginscan_tidrange. > > > + */ > > > +static inline void > > > +table_set_tidrange(TableScanDesc sscan, ItemPointer mintid, > > > + ItemPointer maxtid) > > > +{ > > > + /* Ensure table_beginscan_tidrange() was used. */ > > > + Assert((sscan->rs_flags & SO_TYPE_TIDRANGESCAN) != 0); > > > + > > > + sscan->rs_rd->rd_tableam->scan_set_tidrange(sscan, mintid, maxtid); > > > +} > > > > How does this interact with rescans? > > We must call table_rescan() before calling table_set_tidrange() again. > That perhaps could be documented better. I'm just unsure if that > should be documented in tableam.h or if it's a restriction that only > needs to exist in heapam.c I've changed things around so that we no longer explicitly call table_rescan() in nodeTidrangescan.c. Instead table_set_tidrange() does a rescan call. I also adjusted the documentation to mention that changing the tid range starts the scan again. This does mean we'll do a ->scan_rescan() the first time we do table_set_tidrange(). I'm not all that sure that matters. v15 attached. David
Вложения
В списке pgsql-hackers по дате отправления: