objectbox / objectbox/objectbox-java
Make "between" query conditions use index data
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.6k
- Forks
- 311
- PR merge metrics
- No merged PRs in 30d
Description
Build info
- ObjectBox version: 3.5.0
- OS: Android 14
- Device/ABI/architecture: Pixel 8 Pro
Steps to reproduce
I have a database that contains say 100,000 rows. I try to query 20,000 rows using an id + a between query on an indexed long. It takes ~1.5 seconds in average, sometime up to 5-10s.
Data is frequently written to the database, about 40 times per second. Is that an issue? About 2400 rows are added per second in total between these writes.
The relativeSamplingTimestamp that is used as index has 2 values for the same timestamp in all cases (2 different data streams with same time). Like:
1
1
2
2
3
3
...
Expected behavior
I would expect it to be under a 100ms?
Actual behavior
Takes 1-10 seconds. Average 1.5s.
Code
Code
Schema:
@Id
public long id
public ToOne<LocalSession> localSession;
@Convert(converter = Converters.SerializableConverter.class, dbType = byte[].class)
private HashMap<Integer, Float> samples;
@Convert(converter = Converters.InstantConverter.class, dbType = Long.class)
private Instant receptionTimestamp;
@Nullable
@Index
private Integer relativeSamplingTimestamp;
@Convert(converter = Converters.InstantConverter.class, dbType = Long.class)
@Index
@Nullable
private Instant absoluteSamplingTimestamp;
Query:
samplesRelativeTimestampBetweenQuery = sampleBox.query().equal(Sample_.localSessionId, 0)
.between(Sample_.relativeSamplingTimestamp, 0, 0).build();
Which i then call with parameters like:
samplesRelativeTimestampBetweenQuery.setParameter(
Sample_.localSessionId, localSessionId)
.setParameters(Sample_.relativeSamplingTimestamp, startTimestamp, endTimestamp)
.find())
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named in the issue. Start by reproducing the indexed Java between query with 100,000 rows and concurrent writes on Android, then determine whether the query uses index data; done means the cause and a measured result against the reported sub-100 ms expectation are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- databases, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100