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

Add index on Job Service tables Timestamp column. #2453

Merged

Conversation

richscott
Copy link
Member

@richscott richscott commented May 11, 2023

The Job Service database uses a trigger to invoke a small stored procedure to delete all entries in the jobservice and jobsets tables that have their timestamp column older than the purgeTime configuration value (value is in seconds). This trigger is fired upon each insert to the jobsets table, so the deletes in this proc must be as fast as possible. This change adds an index to the timestamp column of both tables. Manual testing shows a considerable speedup when the tables have 50k or more rows, using EXPLAIN ANALYZE DELETE from .. WHERE....

Also, refactor the table creation logic to make more compact and eliminate repetition of db.Exec(), etc,.

┆Issue is synchronized with this Jira Task by Unito

To improve performance of the trigger-fired stored-proc
to purge old jobsets table entries, by avoiding full table scans
on each delete.

Also, refactor the table creation logic to make more compact and
eliminate repetition of db.Exec(), etc,.
@richscott richscott self-assigned this May 11, 2023
Copy link
Contributor

@ClifHouck ClifHouck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.02 ⚠️

Comparison is base (2b89a23) 58.50% compared to head (6c9d9f8) 58.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2453      +/-   ##
==========================================
- Coverage   58.50%   58.49%   -0.02%     
==========================================
  Files         234      234              
  Lines       29296    29296              
==========================================
- Hits        17140    17136       -4     
- Misses      10842    10844       +2     
- Partials     1314     1316       +2     
Flag Coverage Δ
armada-server 58.49% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@richscott richscott merged commit cbcbd5d into armadaproject:master May 11, 2023
15 checks passed
@richscott richscott deleted the rich/jobservice-timestamp-idx branch May 11, 2023 17:37
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.

None yet

3 participants