From: <di...@us...> - 2010-11-29 15:50:42
|
Revision: 52002 http://firebird.svn.sourceforge.net/firebird/?rev=52002&view=rev Author: dimitr Date: 2010-11-29 15:50:36 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Correction for one of my past commits. Also, unified the code a bit. Modified Paths: -------------- firebird/branches/B2_5_Release/src/jrd/Optimizer.cpp firebird/branches/B2_5_Release/src/jrd/Optimizer.h Modified: firebird/branches/B2_5_Release/src/jrd/Optimizer.cpp =================================================================== --- firebird/branches/B2_5_Release/src/jrd/Optimizer.cpp 2010-11-29 15:06:42 UTC (rev 52001) +++ firebird/branches/B2_5_Release/src/jrd/Optimizer.cpp 2010-11-29 15:50:36 UTC (rev 52002) @@ -1368,21 +1368,6 @@ invCandidate->cost += csb->csb_rpt[stream].csb_cardinality * invCandidate->selectivity; } - // 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++) - { - 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) && - !invCandidate->matches.exist(node)) - { - const double factor = (node->nod_type == nod_eql) ? - REDUCE_SELECTIVITY_FACTOR_EQUALITY : REDUCE_SELECTIVITY_FACTOR_INEQUALITY; - invCandidate->selectivity *= factor; - } - } - // Add the streams where this stream is depending on. for (size_t i = 0; i < invCandidate->matches.getCount(); i++) { findDependentFromStreams(invCandidate->matches[i], &invCandidate->dependentFromStreams); @@ -1576,38 +1561,6 @@ return NULL; } -InversionCandidate* OptimizerRetrieval::getCost() -{ -/************************************** - * - * g e t C o s t - * - ************************************** - * - * Functional description - * - **************************************/ - createIndexScanNodes = false; - setConjunctionsMatched = false; - InversionCandidate* inversion = generateInversion(NULL); - if (inversion) { - return inversion; - } - - // No index will be used, thus - InversionCandidate* invCandidate = FB_NEW(pool) InversionCandidate(pool); - invCandidate->indexes = 0; - invCandidate->selectivity = MAXIMUM_SELECTIVITY; - invCandidate->cost = csb->csb_rpt[stream].csb_cardinality; -/* - OptimizerBlk::opt_conjunct* tail = optimizer->opt_conjuncts.begin(); - for (; tail < optimizer->opt_conjuncts.end(); tail++) { - findDependentFromStreams(tail->opt_conjunct_node, &invCandidate->dependentFromStreams); - } -*/ - return invCandidate; -} - InversionCandidate* OptimizerRetrieval::getInversion(RecordSource** rsb) { /************************************** @@ -1623,18 +1576,35 @@ * an InversionCandidate; * **************************************/ - createIndexScanNodes = true; - setConjunctionsMatched = true; - InversionCandidate* inversion = generateInversion(rsb); - if (inversion) { - return inversion; + createIndexScanNodes = rsb ? true : false; + setConjunctionsMatched = rsb ? true : false; + + InversionCandidate* invCandidate = generateInversion(rsb); + + if (!invCandidate) + { + // No index will be used + invCandidate = FB_NEW(pool) InversionCandidate(pool); + invCandidate->indexes = 0; + invCandidate->selectivity = MAXIMUM_SELECTIVITY; + invCandidate->cost = csb->csb_rpt[stream].csb_cardinality; } - // No index will be used - InversionCandidate* invCandidate = FB_NEW(pool) InversionCandidate(pool); - invCandidate->indexes = 0; - invCandidate->selectivity = MAXIMUM_SELECTIVITY; - invCandidate->cost = csb->csb_rpt[stream].csb_cardinality; + // 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++) + { + 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) && + !invCandidate->matches.exist(node)) + { + const double factor = (node->nod_type == nod_eql) ? + REDUCE_SELECTIVITY_FACTOR_EQUALITY : REDUCE_SELECTIVITY_FACTOR_INEQUALITY; + invCandidate->selectivity *= factor; + } + } + return invCandidate; } Modified: firebird/branches/B2_5_Release/src/jrd/Optimizer.h =================================================================== --- firebird/branches/B2_5_Release/src/jrd/Optimizer.h 2010-11-29 15:06:42 UTC (rev 52001) +++ firebird/branches/B2_5_Release/src/jrd/Optimizer.h 2010-11-29 15:50:36 UTC (rev 52002) @@ -179,9 +179,13 @@ bool outer, bool inner, jrd_nod** sortNode); ~OptimizerRetrieval(); - InversionCandidate* getCost(); InversionCandidate* getInversion(RecordSource** rsb); + InversionCandidate* getCost() + { + return getInversion(NULL); + } + protected: jrd_nod* composeInversion(jrd_nod* node1, jrd_nod* node2, nod_t node_type) const; void findDependentFromStreams(const jrd_nod* node, SortedStreamList* streamList) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |