Skip to content

Conversation

@volokluev
Copy link
Member

@volokluev volokluev commented Jan 20, 2026

Summary

Unifies single-item and cross-item query execution paths by using SQL subqueries instead of fetching trace IDs in separate queries. This simplifies the codebase and improves performance by letting ClickHouse optimize the subquery internally.

Changes

  • Removed get_trace_ids_for_cross_item_query() function that fetched trace IDs in a separate query
  • Enhanced get_trace_ids_sql_for_cross_item_query() to return both SQL string and query result for metadata extraction
  • Refactored EndpointGetTraces to use subquery approach via _execute_with_subquery_optimization()
  • Updated time series and trace item table resolvers to inject SQL subqueries using DangerousRawSQL
  • Added feature flag use_cross_item_path_for_single_item_queries to enable unified path for all queries (not just cross-item)
  • Added test class that runs all existing tests with feature flag enabled to verify parity

Benefits

  • Simplified codebase: Net -101 lines (221 deletions, 120 additions)
  • Unified execution path: Single code path for both query types
  • Better performance: ClickHouse can optimize the subquery internally instead of two round-trips

🤖 Generated with Claude Code

@volokluev volokluev force-pushed the cross_item_one_path branch from d1dae79 to 88ecb2b Compare January 21, 2026 19:14
@volokluev volokluev force-pushed the cross_item_one_path branch from 013ff4b to 87185e6 Compare January 22, 2026 18:35
@volokluev volokluev marked this pull request as ready for review January 23, 2026 20:33
@volokluev volokluev requested review from a team as code owners January 23, 2026 20:33
trace_item_filters_expression,
f.equals(column("item_type"), item_type),
),
# order_by=[OrderBy(OrderByDirection.DESC, column("trace_id"))],
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably can remove this?

@volokluev volokluev enabled auto-merge (squash) January 26, 2026 21:17
@volokluev volokluev merged commit 96b2a13 into master Jan 26, 2026
33 checks passed
@volokluev volokluev deleted the cross_item_one_path branch January 26, 2026 21:58
@getsentry-bot
Copy link
Contributor

revert failed (conflict? already reverted?) -- check the logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants