8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 15:23:03 +01:00

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

This commit is contained in:
Dmitry Yemanov 2024-11-07 12:49:17 +03:00
parent b0c36f09af
commit 79583d675b

View File

@ -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<ValueExprNodeStack> classes;