-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metrics model performance tweaks (#2658)
* Hopefully increase performance for metrics model * sqlmesh format
- Loading branch information
Showing
17 changed files
with
219 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
warehouse/metrics_mesh/models/code/first_contribution_to_artifact.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
TODO: This is a hack for now to fix performance issues with the contributor | ||
classifications. We should use some kind of factory for this in the future to | ||
get all dimensions | ||
*/ | ||
MODEL ( | ||
name metrics.first_contribution_to_artifact, | ||
kind FULL, | ||
partitioned_by (YEAR("time"), "event_source"), | ||
grain (time, event_source, from_artifact_id, to_artifact_id) | ||
); | ||
|
||
SELECT | ||
MIN(time) AS time, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
FROM metrics.first_of_event_from_artifact | ||
WHERE | ||
event_type IN ('COMMIT_CODE', 'ISSUE_OPENED', 'PULL_REQUEST_OPENED', 'PULL_REQUEST_MERGED') | ||
GROUP BY | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id |
24 changes: 24 additions & 0 deletions
24
warehouse/metrics_mesh/models/code/first_contribution_to_collection.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
TODO: This is a hack for now to fix performance issues with the contributor | ||
classifications. We should use some kind of factory for this in the future to | ||
get all dimensions | ||
*/ | ||
MODEL ( | ||
name metrics.first_contribution_to_collection, | ||
kind FULL, | ||
partitioned_by (YEAR("time"), "event_source"), | ||
grain (time, event_source, from_artifact_id, to_collection_id) | ||
); | ||
|
||
SELECT | ||
MIN(time) AS time, | ||
first_contribution_to_project.event_source, | ||
first_contribution_to_project.from_artifact_id, | ||
projects_by_collection_v1.collection_id AS to_collection_id | ||
FROM metrics.first_contribution_to_project | ||
INNER JOIN metrics.projects_by_collection_v1 | ||
ON first_contribution_to_project.to_project_id = projects_by_collection_v1.project_id | ||
GROUP BY | ||
event_source, | ||
from_artifact_id, | ||
to_collection_id |
24 changes: 24 additions & 0 deletions
24
warehouse/metrics_mesh/models/code/first_contribution_to_project.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
TODO: This is a hack for now to fix performance issues with the contributor | ||
classifications. We should use some kind of factory for this in the future to | ||
get all dimensions | ||
*/ | ||
MODEL ( | ||
name metrics.first_contribution_to_project, | ||
kind FULL, | ||
partitioned_by (YEAR("time"), "event_source"), | ||
grain (time, event_source, from_artifact_id, to_project_id) | ||
); | ||
|
||
SELECT | ||
MIN(first_contribution_to_artifact.time) AS time, | ||
first_contribution_to_artifact.event_source, | ||
first_contribution_to_artifact.from_artifact_id, | ||
artifacts_by_project_v1.project_id AS to_project_id | ||
FROM metrics.first_contribution_to_artifact | ||
INNER JOIN metrics.artifacts_by_project_v1 | ||
ON first_contribution_to_artifact.to_artifact_id = artifacts_by_project_v1.artifact_id | ||
GROUP BY | ||
event_source, | ||
from_artifact_id, | ||
to_project_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 8 additions & 11 deletions
19
warehouse/metrics_mesh/models/first_of_event_from_artifact.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
MODEL ( | ||
name metrics.first_of_event_from_artifact, | ||
kind FULL, | ||
partitioned_by (year("time"), "event_type", "event_source"), | ||
grain ( | ||
time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
), | ||
partitioned_by (YEAR("time"), "event_type", "event_source"), | ||
grain (time, event_type, event_source, from_artifact_id, to_artifact_id) | ||
); | ||
select MIN(time) as time, | ||
|
||
SELECT | ||
MIN(time) AS time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
from @oso_source('timeseries_events_by_artifact_v0') | ||
group by event_type, | ||
FROM @oso_source('timeseries_events_by_artifact_v0') | ||
GROUP BY | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id |
19 changes: 8 additions & 11 deletions
19
warehouse/metrics_mesh/models/last_of_event_from_artifact.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
MODEL ( | ||
name metrics.last_of_event_from_artifact, | ||
kind FULL, | ||
partitioned_by (year("time"), "event_type", "event_source"), | ||
grain ( | ||
time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
), | ||
partitioned_by (YEAR("time"), "event_type", "event_source"), | ||
grain (time, event_type, event_source, from_artifact_id, to_artifact_id) | ||
); | ||
select MAX(time) as time, | ||
|
||
SELECT | ||
MAX(time) AS time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
from @oso_source('timeseries_events_by_artifact_v0') | ||
group by event_type, | ||
FROM @oso_source('timeseries_events_by_artifact_v0') | ||
GROUP BY | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.