Skip to content

Query profiling#2011

Merged
g-despot merged 7 commits intodev/1.37from
query-profiling
Apr 17, 2026
Merged

Query profiling#2011
g-despot merged 7 commits intodev/1.37from
query-profiling

Conversation

@g-despot
Copy link
Copy Markdown
Contributor

@g-despot g-despot commented Apr 14, 2026

Summary

Add support for query profiling (#2002). Requires Weaviate >= 1.36.9.

When enabled, the server returns per-shard execution timing breakdowns for search queries. The client exposes this as structured data on all query return types.

Changes

  • Proto: Regenerated search_get_pb2 (all 3 protobuf version variants) from Weaviate v1.36.9 protos to add MetadataRequest.query_profile (field 11), SearchReply.query_profile (field 6), and the QueryProfile message
  • Request: Added query_profile: bool to MetadataQuery, _MetadataQuery, and the METADATA type alias. Wired through _metadata_to_grpc()
  • Response: Added QueryProfileReturn, ShardProfileReturn, SearchProfileReturn dataclasses. Added query_profile: Optional[QueryProfileReturn] to QueryReturn, GenerativeReturn, GroupByReturn, and GenerativeGroupByReturn
  • Version gate: Raises WeaviateUnsupportedFeatureError when query_profile=True is used against a server < 1.36.9
  • Opt-in: MetadataQuery.full() does not include query_profile (profiling has overhead)

Usage

result = collection.query.near_vector(
    near_vector=[1.0, 0.0, 0.0],
    return_metadata=MetadataQuery(query_profile=True, distance=True),
)

for shard in result.query_profile.shards:
    print(f"Shard: {shard.name}, Node: {shard.node}")
    for search_type, profile in shard.searches.items():
        print(f"  {search_type}: {profile.details}")

Test plan

  • 332 existing unit tests pass
  • 8 new integration tests against Weaviate v1.37.0-rc.1:
    • test_fetch_objects_with_query_profile — object lookup returns "object" search profile
    • test_near_vector_with_query_profile — vector search returns HNSW metrics
    • test_bm25_with_query_profile — BM25 returns keyword metrics (kwd_method, kwd_time, etc.)
    • test_hybrid_with_query_profile — hybrid returns both "vector" and "keyword" profiles
    • test_near_vector_group_by_with_query_profile — group-by with profiling
    • test_no_query_profile_when_not_requested — opt-in semantics (null when not requested)
    • test_query_profile_with_metadata_list — list-style metadata ["query_profile", "distance"]
    • test_query_profile_details_are_strings — all detail keys/values are non-empty strings

Closes #2002

Copy link
Copy Markdown

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@g-despot g-despot requested a review from byronvoorbach April 15, 2026 08:08
Comment thread weaviate/collections/classes/grpc.py
@g-despot g-despot requested a review from tsmith023 April 16, 2026 14:04
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.83721% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.74%. Comparing base (31737e9) to head (906b35b).
⚠️ Report is 26 commits behind head on dev/1.37.

Files with missing lines Patch % Lines
integration/test_collection_query_profile.py 99.29% 1 Missing ⚠️
weaviate/collections/queries/base_executor.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           dev/1.37    #2011      +/-   ##
============================================
- Coverage     87.54%   86.74%   -0.80%     
============================================
  Files           280      294      +14     
  Lines         22055    22734     +679     
============================================
+ Hits          19308    19721     +413     
- Misses         2747     3013     +266     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@g-despot g-despot merged commit 7e5b1be into dev/1.37 Apr 17, 2026
121 checks passed
@g-despot g-despot deleted the query-profiling branch April 17, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants