Commit 96b2a13
authored
feat(get_traces): use cross item query path for single item query (#7656)
## 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](https://claude.com/claude-code)1 parent 0a77754 commit 96b2a13
File tree
6 files changed
+119
-221
lines changed- snuba/web
- rpc/v1
- resolvers
- R_eap_items
- common
- tests/web/rpc/v1
6 files changed
+119
-221
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| |||
473 | 472 | | |
474 | 473 | | |
475 | 474 | | |
476 | | - | |
477 | | - | |
| 475 | + | |
| 476 | + | |
478 | 477 | | |
479 | 478 | | |
480 | 479 | | |
| 480 | + | |
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
490 | | - | |
| 489 | + | |
491 | 490 | | |
492 | 491 | | |
493 | 492 | | |
494 | | - | |
495 | | - | |
| 493 | + | |
| 494 | + | |
496 | 495 | | |
497 | 496 | | |
498 | 497 | | |
| |||
503 | 502 | | |
504 | 503 | | |
505 | 504 | | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
511 | 510 | | |
512 | 511 | | |
513 | 512 | | |
514 | 513 | | |
515 | 514 | | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
| 515 | + | |
| 516 | + | |
525 | 517 | | |
526 | 518 | | |
527 | 519 | | |
| |||
Lines changed: 19 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
320 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
321 | 324 | | |
322 | 325 | | |
323 | 326 | | |
| |||
347 | 350 | | |
348 | 351 | | |
349 | 352 | | |
350 | | - | |
351 | | - | |
352 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
353 | 356 | | |
354 | 357 | | |
355 | 358 | | |
356 | 359 | | |
357 | | - | |
| 360 | + | |
358 | 361 | | |
359 | 362 | | |
360 | 363 | | |
| |||
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
419 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
420 | 426 | | |
421 | 427 | | |
422 | 428 | | |
| |||
430 | 436 | | |
431 | 437 | | |
432 | 438 | | |
433 | | - | |
| 439 | + | |
434 | 440 | | |
435 | 441 | | |
436 | 442 | | |
| |||
467 | 473 | | |
468 | 474 | | |
469 | 475 | | |
470 | | - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
471 | 479 | | |
472 | 480 | | |
473 | 481 | | |
| |||
Lines changed: 11 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | | - | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
404 | 405 | | |
405 | 406 | | |
406 | 407 | | |
| 408 | + | |
407 | 409 | | |
408 | 410 | | |
409 | 411 | | |
| |||
429 | 431 | | |
430 | 432 | | |
431 | 433 | | |
432 | | - | |
433 | | - | |
434 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
435 | 437 | | |
436 | 438 | | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
| 439 | + | |
441 | 440 | | |
442 | 441 | | |
443 | 442 | | |
| |||
528 | 527 | | |
529 | 528 | | |
530 | 529 | | |
| 530 | + | |
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
| 545 | + | |
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| |||
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
585 | | - | |
| 585 | + | |
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
| |||
0 commit comments