Skip to content

Conversation

@fstagni
Copy link
Contributor

@fstagni fstagni commented Apr 25, 2025

  • do the same for pilot
  • add tests
  • try to avoid the initial loop from taking too long
  • update the v9 notes
  • Port to DiracX

BEGINRELEASENOTES

*WMS:
NEW: JobDB snapshot: use a summary table for jobs in final state

ENDRELEASENOTES

Aims to improve the performance of job and pilot lookups in large Jobs tables by introducing summary tables. This requires the creation of new database tables and includes the following updates:

Description:

  1. New Tables:
CREATE TABLE IF NOT EXISTS JobsHistorySummary (
  Status VARCHAR(32),
  Site VARCHAR(100),
  Owner VARCHAR(32),
  OwnerGroup VARCHAR(128),
  JobGroup VARCHAR(32),
  JobType VARCHAR(32),
  ApplicationStatus VARCHAR(255),
  MinorStatus VARCHAR(128),
  JobCount INT,
  RescheduleSum INT,
  PRIMARY KEY (Status, Site, Owner, OwnerGroup, JobGroup, JobType, ApplicationStatus, MinorStatus)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `PilotsHistorySummary` (
  `GridSite` VARCHAR(128),
  `GridType` VARCHAR(32),
  `Status` VARCHAR(32),
  `PilotCount` INT,
  PRIMARY KEY (`GridSite`,`GridType`,`Status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Benefits:

This change significantly reduces the lookup time for large Jobs tables.

@fstagni fstagni force-pushed the 90_faster_JobDB_summary branch from 46e2c90 to e59342c Compare April 25, 2025 15:41
@fstagni fstagni marked this pull request as ready for review April 25, 2025 15:41
@fstagni fstagni requested a review from atsareg as a code owner April 25, 2025 15:41
@fstagni fstagni marked this pull request as draft April 26, 2025 12:12
@fstagni fstagni force-pushed the 90_faster_JobDB_summary branch 2 times, most recently from be1976f to 8dcc722 Compare April 29, 2025 13:10
@fstagni fstagni force-pushed the 90_faster_JobDB_summary branch 2 times, most recently from 28402f9 to 589f8d9 Compare April 30, 2025 12:03
@fstagni fstagni force-pushed the 90_faster_JobDB_summary branch from 589f8d9 to 59301f1 Compare April 30, 2025 12:23
@fstagni fstagni marked this pull request as ready for review April 30, 2025 12:36
@fstagni fstagni closed this Apr 30, 2025
@fstagni fstagni reopened this Apr 30, 2025
@fstagni fstagni changed the title feat: JobDB snapshot: use a summary table for jobs in final state [9.0] JobDB snapshot: use a summary table for jobs in final state May 5, 2025
@fstagni fstagni closed this May 5, 2025
@fstagni fstagni reopened this May 5, 2025
Copy link
Member

@chrisburr chrisburr left a comment

Choose a reason for hiding this comment

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

Summarising the discussion we just had:

  • Maybe triggers are a better fit for this?
  • If we did keep this implementation (to be discussed if we take this route):
    • The query should be a scheduled job in MySQL itself
    • Have a table showing when the table was last updated rather than using UTCDATE (at which point we could refresh hourly)

@fstagni fstagni force-pushed the 90_faster_JobDB_summary branch 3 times, most recently from 2962712 to d2937d9 Compare May 12, 2025 15:05
@fstagni fstagni force-pushed the 90_faster_JobDB_summary branch from d2937d9 to fb260d8 Compare May 13, 2025 07:50
@fstagni
Copy link
Contributor Author

fstagni commented May 13, 2025

Summarising the discussion we just had:

* Maybe triggers are a better fit for this?

* If we did keep this implementation (to be discussed if we take this route):
  
  * The query should be a scheduled job in MySQL itself
  * Have a table showing when the table was last updated rather than using `UTCDATE` (at which point we could refresh hourly)

I went through a bit different route, mostly for fixing the UTCDATE bug. I did not move to triggers not MySQL jobs because thinking about it, I do not really like "hiding" these stuff in there, though I agree logically they would fit.

@chrisburr chrisburr marked this pull request as draft May 19, 2025 09:15
@fstagni
Copy link
Contributor Author

fstagni commented May 22, 2025

Superseded by #8199

@fstagni fstagni closed this May 22, 2025
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