Slow query performance when using sort_by_field on queries with few matches

オープン
#6,440 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
rust

調査の方向性

まず、提供されたクエリを再現ケースとして使用し、sort_by_field と fast_field_cache を処理する trace-query パスを追跡します。大規模なインデックスで、ソートありとソートなしの実行およびキャッシュ動作を比較し、その後、10 件未満のドキュメントにマッチするクエリによって、大幅なレイテンシーやキャッシュの追い出しが発生しなくなったことを確認します。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Rust
スター
11.8k
フォーク
628
平均マージ
2日 22時間
マージ済み PR(30日)
50

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quickwit-oss/quickwit のほかの issue

quickwit-oss/quickwit の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。