summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2023-12-19 17:54:34 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2023-12-20 14:11:11 +0000
commitb845595dc7f07f411a94a4691b388468a5bc3d89 (patch)
treefbeeb7a153b56885a28f3d9c59f11bce195cacc6 /searchcore
parent66aae3a006e2778789f6f224cf4ecafa834c42cf (diff)
enable sorting on cost
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.h3
3 files changed, 10 insertions, 6 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
index b5224281724..565604826ee 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
@@ -203,7 +203,8 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
trace.addEvent(5, "Build query execution plan");
_query.reserveHandles(_requestContext, searchContext, _mdl);
trace.addEvent(5, "Optimize query execution plan");
- _query.optimize(SortBlueprintsByCost::check(_queryEnv.getProperties(), rankSetup.sort_blueprints_by_cost()));
+ bool sort_by_cost = SortBlueprintsByCost::check(_queryEnv.getProperties(), rankSetup.sort_blueprints_by_cost());
+ _query.optimize(sort_by_cost);
trace.addEvent(4, "Perform dictionary lookups and posting lists initialization");
double hitRate = std::min(1.0, double(maxNumHits)/double(searchContext.getDocIdLimit()));
bool create_postinglist_when_non_strict = CreatePostingListWhenNonStrict::check(_queryEnv.getProperties(), rankSetup.create_postinglist_when_non_strict());
@@ -216,7 +217,8 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
_query.handle_global_filter(_requestContext, searchContext.getDocIdLimit(),
_attribute_blueprint_params.global_filter_lower_limit,
_attribute_blueprint_params.global_filter_upper_limit,
- trace, create_postinglist_when_non_strict, use_estimate_for_fetch_postings);
+ trace, create_postinglist_when_non_strict, use_estimate_for_fetch_postings,
+ sort_by_cost);
}
_query.freeze();
trace.addEvent(5, "Prepare shared state for multi-threaded rank executors");
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index 149828b0a91..dfa1bd91157 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -201,7 +201,7 @@ void
Query::optimize(bool sort_by_cost)
{
(void) sort_by_cost;
- _blueprint = Blueprint::optimize(std::move(_blueprint));
+ _blueprint = Blueprint::optimize(std::move(_blueprint), sort_by_cost);
LOG(debug, "optimized blueprint:\n%s\n", _blueprint->asString().c_str());
}
@@ -215,7 +215,8 @@ void
Query::handle_global_filter(const IRequestContext & requestContext, uint32_t docid_limit,
double global_filter_lower_limit, double global_filter_upper_limit,
search::engine::Trace& trace,
- bool create_postinglist_when_non_strict, bool use_estimate_for_fetch_postings)
+ bool create_postinglist_when_non_strict, bool use_estimate_for_fetch_postings,
+ bool sort_by_cost)
{
if (!handle_global_filter(*_blueprint, docid_limit, global_filter_lower_limit, global_filter_upper_limit,
requestContext.thread_bundle(), &trace))
@@ -224,7 +225,7 @@ Query::handle_global_filter(const IRequestContext & requestContext, uint32_t doc
}
// optimized order may change after accounting for global filter:
trace.addEvent(5, "Optimize query execution plan to account for global filter");
- _blueprint = Blueprint::optimize(std::move(_blueprint));
+ _blueprint = Blueprint::optimize(std::move(_blueprint), sort_by_cost);
LOG(debug, "blueprint after handle_global_filter:\n%s\n", _blueprint->asString().c_str());
// strictness may change if optimized order changed:
fetchPostings(ExecuteInfo::create(true, 1.0, requestContext.getDoom(), requestContext.thread_bundle(),
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.h b/searchcore/src/vespa/searchcore/proton/matching/query.h
index 8062f12b70d..b468b4b8f33 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.h
@@ -109,7 +109,8 @@ public:
void handle_global_filter(const IRequestContext & requestContext, uint32_t docid_limit,
double global_filter_lower_limit, double global_filter_upper_limit,
search::engine::Trace& trace,
- bool create_postinglist_when_non_strict, bool use_estimate_for_fetch_postings);
+ bool create_postinglist_when_non_strict, bool use_estimate_for_fetch_postings,
+ bool sort_by_cost);
/**
* Calculates and handles the global filter if needed by the blueprint tree.