api
api copied to clipboard
Chore: refactor PR histogram bucket generation query
The PR time_bucket
query to timescale is not performant:
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:
https://github.com/open-sauced/api/blob/5f9897c1024747820387c744f3dd0abfdb9b704f/src/timescale/pull_request_github_events.service.ts#L498-L504
Regardless, this needs a second look.