mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 04:43:03 +01:00
Slightly changed a bugfix for CORE-2078 to avoid affecting indexed retrievals.
It's a compromise targeted to resolve any regressions in v2.1.2 (like CORE-2411).
This commit is contained in:
parent
483c40b420
commit
a7b6702021
@ -3057,19 +3057,22 @@ bool OptimizerInnerJoin::estimateCost(USHORT stream, double *cost,
|
||||
double selectivity = candidate->selectivity;
|
||||
*cost = candidate->cost;
|
||||
|
||||
// Adjust the effective selectivity based on non-indexed conjunctions
|
||||
for (const OptimizerBlk::opt_conjunct* tail = optimizer->opt_conjuncts.begin();
|
||||
tail < optimizer->opt_conjuncts.end(); tail++)
|
||||
if (!candidate->indexes)
|
||||
{
|
||||
jrd_nod* const node = tail->opt_conjunct_node;
|
||||
if (!(tail->opt_conjunct_flags & opt_conjunct_used) &&
|
||||
OPT_computable(optimizer->opt_csb, node, stream, false, true) &&
|
||||
!candidate->matches.exist(node))
|
||||
// If indices are not involved, adjust the effective selectivity
|
||||
// by treating computable conjunctions as filters
|
||||
for (const OptimizerBlk::opt_conjunct* tail = optimizer->opt_conjuncts.begin();
|
||||
tail < optimizer->opt_conjuncts.end(); tail++)
|
||||
{
|
||||
const double factor = (node->nod_type == nod_eql) ?
|
||||
REDUCE_SELECTIVITY_FACTOR_EQUALITY :
|
||||
REDUCE_SELECTIVITY_FACTOR_INEQUALITY;
|
||||
selectivity *= factor;
|
||||
jrd_nod* const node = tail->opt_conjunct_node;
|
||||
if (!(tail->opt_conjunct_flags & opt_conjunct_used) &&
|
||||
OPT_computable(optimizer->opt_csb, node, stream, false, true))
|
||||
{
|
||||
const double factor = (node->nod_type == nod_eql) ?
|
||||
REDUCE_SELECTIVITY_FACTOR_EQUALITY :
|
||||
REDUCE_SELECTIVITY_FACTOR_INEQUALITY;
|
||||
selectivity *= factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user