Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Hotfix for search performance (meilisearch#1707) #378

Merged
merged 3 commits into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions milli/src/search/criteria/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ impl<'t, 'q> WordLevelIterator<'t, 'q> {
in_prefix_cache: bool,
) -> heed::Result<Option<Self>> {
match ctx.word_position_last_level(&word, in_prefix_cache)? {
Some(level) => {
Some(_) => {
// HOTFIX Meilisearch#1707: it is better to only iterate over level 0 for performances reasons.
let level = TreeLevel::min_value();
let interval_size = LEVEL_EXPONENTIATION_BASE.pow(Into::<u8>::into(level) as u32);
let inner =
ctx.word_position_iterator(&word, level, in_prefix_cache, None, None)?;
Expand Down Expand Up @@ -528,10 +530,10 @@ impl<'t, 'q> Branch<'t, 'q> {
fn cmp(&self, other: &Self) -> Ordering {
let self_rank = self.compute_rank();
let other_rank = other.compute_rank();
let left_cmp = self_rank.cmp(&other_rank).reverse();
let left_cmp = self_rank.cmp(&other_rank);
// on level: lower is better,
// we want to dig faster into levels on interesting branches.
let level_cmp = self.tree_level.cmp(&other.tree_level).reverse();
let level_cmp = self.tree_level.cmp(&other.tree_level);

left_cmp.then(level_cmp).then(self.last_result.2.len().cmp(&other.last_result.2.len()))
}
Expand Down