Slow query performance when using sort_by_field on queries with few matches

未关闭
#6,440 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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 小时
30 天内合并 PR
50

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

quickwit-oss/quickwit 的其他 Issue

查看 quickwit-oss/quickwit 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。