From 79583d675b6612aaabcf5618e91ee392864d67a6 Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Thu, 7 Nov 2024 12:49:17 +0300 Subject: [PATCH] Rework my fix for #5654: Could not execute query (select from view with nested view) -- the original solution was too restrictive, causing regressions in plans/performance --- src/jrd/optimizer/Optimizer.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/jrd/optimizer/Optimizer.cpp b/src/jrd/optimizer/Optimizer.cpp index 612dee10d1..1dc090dd54 100644 --- a/src/jrd/optimizer/Optimizer.cpp +++ b/src/jrd/optimizer/Optimizer.cpp @@ -1971,14 +1971,15 @@ void Optimizer::checkSorts() unsigned Optimizer::distributeEqualities(BoolExprNodeStack& orgStack, unsigned baseCount) { - // dimitr: Dumb protection against too many injected conjuncts (see CORE-5381). - // Don't produce more additional conjuncts than we originally had - // (i.e. this routine should never more than double the number of conjuncts). - // Ideally, we need two separate limits here: - // 1) number of injected conjuncts (affects required impure size) - // 2) number of input conjuncts (affects search time inside this routine) + // dimitr: Simplified protection against too many injected conjuncts (see CORE-5381). + // Two separate limits are applied here: + // 1) number of input conjuncts (affects search time inside this routine) + // 2) number of injected conjuncts (affects required impure size) - if (baseCount * 2 > MAX_CONJUNCTS) + constexpr unsigned MAX_CONJUNCTS_TO_PROCESS = 1024; + const unsigned MAX_CONJUNCTS_TO_INJECT = MAX(baseCount, 256); + + if (baseCount > MAX_CONJUNCTS_TO_PROCESS) return 0; ObjectsArray classes;