# Evaluating Range Predicates

DevFeed: [Evaluating Range Predicates](<https://devfeed.tech/articles/evaluating-range-predicates-25644.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/range-predicates>)

Author: Richard Startin's Blog

Published: 2022-03-12T00:00:00Z

Content type: article

Language: en

Sources: [Richard Startin](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Data analysis](<https://devfeed.tech/topics/data-analysis.md>), [ordering](<https://devfeed.tech/topics/ordering.md>), [Tool](<https://devfeed.tech/topics/tool.md>)

Tags: [about](<https://devfeed.tech/tags/about.md>), [all](<https://devfeed.tech/tags/all.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [api](<https://devfeed.tech/tags/api.md>), [application](<https://devfeed.tech/tags/application.md>), [applying](<https://devfeed.tech/tags/applying.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [benefit](<https://devfeed.tech/tags/benefit.md>), [binary-search](<https://devfeed.tech/tags/binary-search.md>), [branch](<https://devfeed.tech/tags/branch.md>), [complex](<https://devfeed.tech/tags/complex.md>), [data](<https://devfeed.tech/tags/data.md>), [data-analysis](<https://devfeed.tech/tags/data-analysis.md>), [doing](<https://devfeed.tech/tags/doing.md>), [java](<https://devfeed.tech/tags/java.md>), [kind](<https://devfeed.tech/tags/kind.md>), [range](<https://devfeed.tech/tags/range.md>), [roaring](<https://devfeed.tech/tags/roaring.md>), [sales](<https://devfeed.tech/tags/sales.md>), [transaction](<https://devfeed.tech/tags/transaction.md>), [transactions](<https://devfeed.tech/tags/transactions.md>)

## AI overview

For Java filtering over data that cannot be queried through SQL, predicate order and data layout affect performance. In the author's benchmark on one million transactions, reordering conditions to evaluate predictable checks first halved runtime and reduced branch misses by about 10x. When timestamps are sorted and the selected range covers about 10% of the data, binary searching for its bounds could improve performance by up to about 10x; the benchmark excludes sorting, which may pay off when multiple filters reuse the collection. The excerpt also identifies RoaringBitmap as a data structure for range predicates on unsorted data, describing it as immutable and suited to data with a known value range; it suggests building indexes on multiple attributes may be worthwhile when applying several filters.

## Source excerpt

Suppose you are doing some kind of data analysis in Java, perhaps you are analysing transactions (as in sales made). You have complex filters to evaluate before performing a calculation on Transaction objects.