From 6bd9f709769806f3b79a47b67a26b46cccf35e63 Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Tue, 11 Apr 2023 21:04:08 +0200 Subject: [PATCH] remove filters when using precalc sorters; CBO tuning --- src/costestimate.cpp | 2 +- src/costestimate.h | 1 + src/sphinx.cpp | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/costestimate.cpp b/src/costestimate.cpp index 9d84ceb643..2b22430e07 100644 --- a/src/costestimate.cpp +++ b/src/costestimate.cpp @@ -362,7 +362,7 @@ float CostEstimate_c::CalcQueryCost() } if ( iNumFilters ) - fCost += CalcFilterCost ( iToIntersect>0, fDocsAfterIndexes ); + fCost += CalcFilterCost ( m_tCtx.m_bFromIterator || iToIntersect>0, fDocsAfterIndexes ); if ( iNumLookups ) fCost += CalcLookupCost(); diff --git a/src/costestimate.h b/src/costestimate.h index 8fefaf704e..fd1c50f6f8 100644 --- a/src/costestimate.h +++ b/src/costestimate.h @@ -51,6 +51,7 @@ struct SelectIteratorCtx_t int64_t m_iTotalDocs = 0; int m_iThreads = 1; bool m_bCalcPushCost = true; + bool m_bFromIterator = false; SelectIteratorCtx_t ( const CSphVector & dFilters, const CSphVector & dFilterTree, const CSphVector & dHints, const ISphSchema & tSchema, const HistogramContainer_c * pHistograms, columnar::Columnar_i * pColumnar, SI::Index_i * pSI, ESphCollation eCollation, int iCutoff, int64_t iTotalDocs, int iThreads ); diff --git a/src/sphinx.cpp b/src/sphinx.cpp index 32c7df0079..4f4f4723b0 100644 --- a/src/sphinx.cpp +++ b/src/sphinx.cpp @@ -8002,6 +8002,7 @@ bool CSphIndex_VLN::SelectIteratorsFT ( const CSphQuery & tQuery, ISphRanker * p i.m_iRsetEstimate *= fRatio; tSelectIteratorCtx.m_iTotalDocs = tEstimate.m_iDocs; + tSelectIteratorCtx.m_bFromIterator = true; std::unique_ptr pCostEstimate ( CreateCostEstimate ( dSIInfoFilters, tSelectIteratorCtx ) ); fCostOfFilters = pCostEstimate->CalcQueryCost(); } @@ -8190,7 +8191,9 @@ bool CSphIndex_VLN::MultiScan ( CSphQueryResult & tResult, const CSphQuery & tQu // try to spawn an iterator from a secondary index CSphVector dModifiedFilters; // holds filter settings if they were modified. filters hold pointers to those settings std::unique_ptr pIterator; - if ( !bAllPrecalc ) + if ( bAllPrecalc ) + tCtx.m_pFilter.reset(); + else pIterator = std::unique_ptr ( SpawnIterators ( tQuery, tCtx, tFlx, tMaxSorterSchema, tMeta, iCutoff, tArgs.m_iTotalThreads, dModifiedFilters, nullptr ) ); SwitchProfile ( tMeta.m_pProfile, SPH_QSTATE_FULLSCAN );