Slow query performance when using sort_by_field on queries with few matches

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

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rust
Lĩnh vực
performance, search

Hướng nghiên cứu

Bắt đầu bằng cách lần theo đường đi của trace-query xử lý sort_by_field và fast_field_cache, sử dụng truy vấn được cung cấp làm trường hợp tái hiện. So sánh việc thực thi và hành vi của cache khi có và không có sắp xếp trên một chỉ mục lớn, sau đó xác nhận rằng một truy vấn khớp với ít hơn 10 tài liệu không còn gây ra độ trễ đáng kể hoặc việc loại bỏ mục khỏi cache.

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

Mô tả

area:performance area:search bug

Describe the bug
I noticed that the following query becomes significantly slower when sort_by_field is specified:

When I remove sort_by_field, the same query becomes very fast. I also observed a large increase in fast_field_cache evict_bytes while running the query.

However, the query only returns fewer than 10 documents, which is far below max_hits. Based on this behavior, it seems that the sort operation may be scanning or loading fast field data before applying the query filter. If that is the case, it appears inefficient and unexpected.

{"query":"trace_id:\"0002e641f5b84161f35b907c8fce3039\"","max_hits":100,"start_timestamp":1771303321,"end_timestamp":1779079322,"sort_by_field":"span_start_timestamp_nanos"}

Steps to reproduce (if applicable)

  1. Ingest a large number of traces so that the fast-field cache capacity is exceeded.
  2. Run a trace query with sort_by_field enabled.
  3. Compare the latency and fast_field_cache evict_bytes with the same query executed without sort_by_field.

Expected behavior
The query filter should be applied first, and sorting should only be performed on the matched documents. In this case, since the query matches fewer documents, adding sort_by_field should not significantly increase query latency or cause substantial fast-field cache eviction.

Configuration:

  1. v0.9.0-rc
  2. Index template: official otel-traces-v0_9 index
Ngôn ngữ chính
Rust
Star
11.8k
Fork
628
Merge trung bình
2 ngày 22 giờ
Pull request đã merge (30 ngày)
50

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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.

Issue khác của quickwit-oss/quickwit

Tất cả issue của quickwit-oss/quickwit

Issue tương tự

Thêm issue về Rust

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.