@@ -591,11 +591,10 @@ namespace
591
591
//
592
592
593
593
Optimizer::Optimizer (thread_db* aTdbb, CompilerScratch* aCsb, RseNode* aRse,
594
- bool parentFirstRows, double parentCardinality )
594
+ bool parentFirstRows)
595
595
: PermanentStorage(*aTdbb->getDefaultPool ()),
596
596
tdbb(aTdbb), csb(aCsb), rse(aRse),
597
597
firstRows(rse->firstRows.valueOr(parentFirstRows)),
598
- cardinality(parentCardinality),
599
598
compileStreams(getPool()),
600
599
bedStreams(getPool()),
601
600
keyStreams(getPool()),
@@ -651,7 +650,7 @@ RecordSource* Optimizer::compile(RseNode* subRse, BoolExprNodeStack* parentStack
651
650
// if we're going to sort/aggregate the resultset afterwards
652
651
const bool subFirstRows = firstRows && !rse->rse_sorted && !rse->rse_aggregate ;
653
652
654
- Optimizer subOpt (tdbb, csb, subRse, subFirstRows, cardinality );
653
+ Optimizer subOpt (tdbb, csb, subRse, subFirstRows);
655
654
const auto rsb = subOpt.compile (parentStack);
656
655
657
656
if (parentStack && subOpt.isInnerJoin ())
@@ -702,31 +701,11 @@ RecordSource* Optimizer::compile(BoolExprNodeStack* parentStack)
702
701
703
702
conjunctCount += distributeEqualities (conjunctStack, conjunctCount);
704
703
705
- if (parentStack)
706
- {
707
- // AB: If we have limit our retrieval with FIRST / SKIP syntax then
708
- // we may not deliver above conditions (from higher rse's) to this
709
- // rse, because the results should be consistent.
710
- if (rse->rse_skip || rse->rse_first )
711
- parentStack = nullptr ;
712
-
713
- if (isSpecialJoin () && parentStack->hasData ())
714
- {
715
- // We have a semi-join, look at the parent (priorly joined streams) cardinality.
716
- // If it's known to be not very small, nullify the parent conjuncts
717
- // to give up a possible nested loop join in favor of a hash join.
718
- // Here we assume every equi-join condition having a default selectivity (0.1).
719
- // TODO: replace with a proper cost-based decision in the future.
720
-
721
- double subSelectivity = MAXIMUM_SELECTIVITY;
722
- for (auto count = parentStack->getCount (); count; count--)
723
- subSelectivity *= DEFAULT_SELECTIVITY;
724
- const auto thresholdCardinality = MINIMUM_CARDINALITY / subSelectivity;
725
-
726
- if (!cardinality || cardinality > thresholdCardinality)
727
- parentStack = nullptr ;
728
- }
729
- }
704
+ // AB: If we have limit our retrieval with FIRST / SKIP syntax then
705
+ // we may not deliver above conditions (from higher rse's) to this
706
+ // rse, because the results should be consistent.
707
+ if (rse->rse_skip || rse->rse_first )
708
+ parentStack = nullptr ;
730
709
731
710
// Set base-point before the parent/distributed nodes begin.
732
711
const unsigned baseCount = conjunctCount;
@@ -905,7 +884,7 @@ RecordSource* Optimizer::compile(BoolExprNodeStack* parentStack)
905
884
bool computable = false ;
906
885
907
886
// AB: Save all outer-part streams
908
- if (isInnerJoin () || (isLeftJoin () && !innerSubStream))
887
+ if (isInnerJoin () || (( isLeftJoin () || isSpecialJoin () ) && !innerSubStream))
909
888
{
910
889
if (node->computable (csb, INVALID_STREAM, false ))
911
890
computable = true ;
0 commit comments