Last active
March 29, 2022 18:43
-
-
Save Intelrunner/1a1c7448cba5cc14daa5ef8e164050dd to your computer and use it in GitHub Desktop.
This Query Estimates slot usage per SECOND at an organizational level, segregated by project_id. Use: Finding average number of slot seconds per second to determine if purchasing Google Cloud Platform Bigquery Slots is valuable for an organization. Requires: bigquery.jobs.listAll
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
SELECT | |
TIMESTAMP_TRUNC(jobs.start_time, second) as sec, | |
SUM(SAFE_DIVIDE(total_slot_ms, TIMESTAMP_DIFF(end_time, start_time, MILLISECOND))) AS Slot_Count, project_ID as project | |
FROM | |
`region-us`.INFORMATION_SCHEMA.JOBS_BY_ORGANIZATION jobs | |
WHERE jobs.start_time BETWEEN TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 3 DAY) AND CURRENT_TIMESTAMP() | |
GROUP BY project_id, sec | |
ORDER BY sec DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recommend this is run at 3 day intervals for 1M and average usage is aggregated over that time. Inter-departmental data cycles need to be accounted for to prevent over-purchase.