diff --git a/src/jrd/recsrc/FilteredStream.cpp b/src/jrd/recsrc/FilteredStream.cpp index 9f1e6dcf9f..d3fa6209fc 100644 --- a/src/jrd/recsrc/FilteredStream.cpp +++ b/src/jrd/recsrc/FilteredStream.cpp @@ -50,9 +50,13 @@ FilteredStream::FilteredStream(CompilerScratch* csb, RecordSource* next, m_impure = csb->allocImpure(); - const auto cardinality = next->getCardinality(); - Optimizer::adjustSelectivity(selectivity, MAXIMUM_SELECTIVITY, cardinality); - m_cardinality = cardinality * selectivity; + auto cardinality = next->getCardinality(); + if (selectivity) + { + Optimizer::adjustSelectivity(selectivity, MAXIMUM_SELECTIVITY, cardinality); + cardinality *= selectivity; + } + m_cardinality = cardinality; } void FilteredStream::internalOpen(thread_db* tdbb) const diff --git a/src/jrd/recsrc/RecordSource.h b/src/jrd/recsrc/RecordSource.h index 0d0d5b6044..ee65daf6f1 100644 --- a/src/jrd/recsrc/RecordSource.h +++ b/src/jrd/recsrc/RecordSource.h @@ -575,7 +575,7 @@ namespace Jrd { public: FilteredStream(CompilerScratch* csb, RecordSource* next, - BoolExprNode* boolean, double selectivity); + BoolExprNode* boolean, double selectivity = 0); void close(thread_db* tdbb) const override; @@ -623,7 +623,7 @@ namespace Jrd public: PreFilteredStream(CompilerScratch* csb, RecordSource* next, BoolExprNode* boolean) - : FilteredStream(csb, next, boolean, next->getCardinality()) + : FilteredStream(csb, next, boolean) { m_invariant = true; }