objectbox / objectbox/objectbox-java

Make "between" query conditions use index data

Đang mở
#1,186 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement
Ngôn ngữ chính
Java
Star
4.6k
Fork
311
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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())

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Issue không nêu tên tệp nào trong repository hoặc các bài kiểm thử. Hãy bắt đầu bằng cách tái hiện truy vấn between Java được lập chỉ mục với 100.000 hàng và các thao tác ghi đồng thời trên Android, sau đó xác định xem truy vấn có sử dụng dữ liệu chỉ mục hay không; công việc được xem là hoàn tất khi đã xác định được nguyên nhân và kết quả đo được so với kỳ vọng dưới 100 ms được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, java
Lĩnh vực
databases, performance
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.