From bf4e0892717390bfb8e8866449d49c12658ceff0 Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Fri, 13 Mar 2020 20:38:09 +0300 Subject: [PATCH] Fixed the sub-optimal plan reported by Vlad privately --- src/jrd/RecordSourceNodes.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jrd/RecordSourceNodes.cpp b/src/jrd/RecordSourceNodes.cpp index 3d2ba96cbc..5f75e756a3 100644 --- a/src/jrd/RecordSourceNodes.cpp +++ b/src/jrd/RecordSourceNodes.cpp @@ -2939,7 +2939,10 @@ void RseNode::pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, // where we are just trying to inner join more than 2 streams. If possible, // try to flatten the tree out before we go any further. - if (!rse->rse_jointype && !rse_jointype && !rse_sorted && !rse_projection && + const auto isLateral = (this->flags & RseNode::FLAG_LATERAL) != 0; + + if (!isLateral && !rse->rse_jointype && !rse_jointype && + !rse_sorted && !rse_projection && !rse_first && !rse_skip && !rse_plan) { NestConst* arg = rse_relations.begin();