Amit Langote <langote_amit...@lab.ntt.co.jp> writes:
> On 2018/07/16 2:02, Tom Lane wrote:
>> BTW, there'd be a lot to be said for having InitPlan just open all
>> the rels and build an array of Relation pointers that parallels the
>> RTE list, rather than doing heap_opens in random places elsewhere.

> +1 to this.  Actually I had written such a patch in place of the one I
> posted on this thread, but wasn't confident enough that I had found and
> fixed all the places in the executor that would use the Relation pointer
> from there instead of fetching it themselves.

Well, it doesn't have to be a 100% conversion, especially not to start
out with.  As long as we ensure that common code paths through the
executor have only one open/close per rel, I don't think it matters
too much if there are some corner cases with more.

Also, tracking down places like that wouldn't be that hard to do.  One
could instrument the relcache to report situations where a rel's refcount
gets above 1.  (The infrastructure for logging backtraces that's being
discussed in other threads would help here.)  We might decide that
particular cases weren't worth fixing --- eg if the extra open is
happening in code that doesn't have easy access to the EState --- but
I doubt that finding them is impractical.

                        regards, tom lane

Reply via email to