Skip to content

Script to identify when was the table last accessed based on INFORMATION_SCHEMA.JOBS #483

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pratik-m
Copy link

@pratik-m pratik-m commented Mar 16, 2025

BigQuery Table Access and Usage Analysis Script
This script analyzes BigQuery job history to determine when tables were last accessed and provides insights into Data Manipulation Language (DML) and Data Definition Language (DDL) operations performed on those tables.
It helps identify:

  • The last time a table was referenced in a query (last accessed time).
  • The frequency of SELECT, INSERT, UPDATE, DELETE, TRUNCATE, and other DDL/DML operations.
    This information is valuable for:
  • Identifying unused tables for potential deletion to optimize storage costs.
  • Understanding table usage patterns for performance tuning and resource allocation.

Please share your feedback and suggestion!

Copy link

google-cla bot commented Mar 16, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@afleisc
Copy link
Collaborator

afleisc commented Mar 19, 2025

Hi @pratik-m thanks for the PR! A couple of things,

  • Please sign the google CLA in the above comment
  • Looks like there are some syntax errors around the temp table statement, can you please resolve any syntax errors ?
  • This script appears to be more of an audit use case, do you mind creating a folder called audit under scripts and placing this sql file there?

@pratik-m
Copy link
Author

Hi @afleisc - Thanks for the comments. I'll review and fix the script and move it to the audit folder. thanks!

Script to identify when was the table last accessed based on
`INFORMATION_SCHEMA.JOBS`
@pratik-m
Copy link
Author

Hi @afleisc - I';ve done the requested changes. Please review and let me know if any suggestions or feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants