iroha
iroha copied to clipboard
Add optimizations for primary key queries
TL;DR
After #4833 lands, there will be a degradation in performance of primary-key queries compared to before (linear scan is being used instead of looking up a map). An special case should be created for the primary-key queries, as outlined in https://github.com/hyperledger/iroha/pull/4833#discussion_r1679031539:
let iter: Box<dyn Iterator<Item = Domain>> = match filter {
CompoundPredicate::Atom(DomainPredicateBox::Id(DomainIdPredicateBox::Equals(
domain_id,
))) => Box::new(Some(state_ro
.world()
.domain(&domain_id)?
.clone())
.into_iter()),
filter => Box::new(
state_ro
.world()
.domains_iter()
.filter(move |&v| filter.applies(v))
.cloned(),
),
};
Ok(iter)