Skip to content
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

Chore: refactor PR histogram bucket generation query #694

Open
jpmcb opened this issue Mar 29, 2024 · 0 comments
Open

Chore: refactor PR histogram bucket generation query #694

jpmcb opened this issue Mar 29, 2024 · 0 comments
Assignees
Labels
chore label to mark dependency and documentation updates core team work

Comments

@jpmcb
Copy link
Member

jpmcb commented Mar 29, 2024

The PR time_bucket query to timescale is not performant:

Screenshot 2024-03-29 at 7 48 02 AM

this is a screenshot from some insights on timescale we can see and the medium time is way too slow. Which is surprising since it's using a hypertable and should be reporting faster results. There may be outliers but if I had to guess, it's because we build a partition table to then build the time series from in the genPrHistogram function:

const cteBuilder = this.pullRequestGithubEventsRepository
.createQueryBuilder("pull_request_github_events")
.select("*")
.addSelect(`ROW_NUMBER() OVER (PARTITION BY pr_number, repo_name ORDER BY event_time ${order}) AS row_num`)
.orderBy("event_time", order)
.where(`'${startDate}'::TIMESTAMP >= "pull_request_github_events"."event_time"`)
.andWhere(`'${startDate}'::TIMESTAMP - INTERVAL '${range} days' <= "pull_request_github_events"."event_time"`);

Regardless, this needs a second look.

@jpmcb jpmcb added chore label to mark dependency and documentation updates core team work labels Mar 29, 2024
@jpmcb jpmcb self-assigned this Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore label to mark dependency and documentation updates core team work
Projects
None yet
Development

No branches or pull requests

1 participant