Alvaro Herrera <alvhe...@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