-
Notifications
You must be signed in to change notification settings - Fork 498
query timing route #1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query timing route #1146
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis refactoring separates query execution from timing retrieval. The analytics query endpoint now returns a query_id instead of CPU and wall-clock stats. A new /timing endpoint fetches timing statistics using the query_id. Changes include a project-scoped timing helper function, updated response types, and expanded test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant QueryAPI as Query API<br/>/query
participant TimingAPI as Timing API<br/>/query/timing
participant ClickHouse
rect rgba(200, 150, 100, 0.5)
Note over Client,ClickHouse: New Flow: Separate Query & Timing
Client->>QueryAPI: POST with analytics query
activate QueryAPI
QueryAPI->>ClickHouse: Execute query
ClickHouse-->>QueryAPI: Query result
QueryAPI-->>Client: { result: [...], query_id: "proj_branch_uuid" }
deactivate QueryAPI
Note over Client,ClickHouse: Client later fetches timing
Client->>TimingAPI: POST with query_id
activate TimingAPI
TimingAPI->>ClickHouse: Query system.query_log
ClickHouse-->>TimingAPI: Timing stats (cpu_time, wall_clock_time)
TimingAPI-->>Client: { cpu_time: X, wall_clock_time: Y }
deactivate TimingAPI
end
rect rgba(100, 150, 200, 0.5)
Note over Client,ClickHouse: Previous Flow: Combined Query & Timing
Client->>QueryAPI: POST with analytics query
activate QueryAPI
QueryAPI->>ClickHouse: Execute & fetch timing stats
ClickHouse-->>QueryAPI: Result + timing metrics
QueryAPI-->>Client: { result: [...], stats: { cpu_time, wall_clock_time } }
deactivate QueryAPI
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile OverviewGreptile SummaryRefactored analytics query execution to return query timing statistics via a separate endpoint instead of inline. The Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant QueryRoute as /analytics/query
participant TimingRoute as /analytics/query/timing
participant ClickHouse
participant QueryLog as system.query_log
Client->>QueryRoute: POST with query & params
QueryRoute->>QueryRoute: Generate queryId<br/>(projectId:branchId:uuid)
QueryRoute->>ClickHouse: Execute query with queryId
ClickHouse-->>QueryRoute: Query results
QueryRoute-->>Client: Return results + queryId
Note over QueryLog: ClickHouse logs query<br/>to system.query_log<br/>(async, up to 7.5s delay)
Client->>TimingRoute: POST with queryId
TimingRoute->>TimingRoute: Validate queryId prefix<br/>(projectId:branchId)
TimingRoute->>QueryLog: Query timing stats (with retry)
alt Stats available
QueryLog-->>TimingRoute: cpu_time_ms, wall_clock_time_ms
TimingRoute-->>Client: Return stats
else Stats not found after retries
TimingRoute-->>Client: 404 Not Found
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
Summary by CodeRabbit
New Features
Improvements