Re: More efficient RI checks - take 2 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: More efficient RI checks - take 2
Date
Msg-id 2414.1587500093@sss.pgh.pa.us
Whole thread Raw
In response to Re: More efficient RI checks - take 2  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: More efficient RI checks - take 2  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> I do wonder if the RI stuff would actually end up being faster without
> SPI.  If not, we'd only end up writing more code to do the same thing.
> Now that tables can be partitioned, it is much more of a pain than when
> only regular tables could be supported.  Obviously without SPI you
> wouldn't *have* to go through the planner, which might be a win in
> itself if the execution tree to use were always perfectly clear ... but
> now that the queries get more complex per partitioning and this
> optimization, is it?

AFAIK, we do not have any code besides the planner that is capable of
building a plan tree at all, and I'd be pretty hesitant to try to create
such; those things are complicated.

It'd likely only make sense to bypass the planner if the required work
is predictable enough that you don't need a plan tree at all, but can
just hard-wire what has to be done.  That seems a bit unlikely in the
presence of partitioning.

Instead of a plan tree, you could build a parse tree to pass through the
planner, rather than building a SQL statement string that has to be
parsed.  The code jumps through enough hoops to make sure the string will
be parsed "just so" that this might net out to about an equal amount of
code in ri_triggers.c, and it'd save a nontrivial amount of parsing work.
But you'd have to abandon SPI, probably, or at least it's not clear how
much that'd be doing for you anymore.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: design for parallel backup
Next
From: Robert Haas
Date:
Subject: Re: design for parallel backup