Skip to content

Optimize removeTrigger method - #1436

Open
kkalin68 wants to merge 1 commit into
quartz-scheduler:mainfrom
kkalin68:optimize_remove_trigger
Open

Optimize removeTrigger method#1436
kkalin68 wants to merge 1 commit into
quartz-scheduler:mainfrom
kkalin68:optimize_remove_trigger

Conversation

@kkalin68

Copy link
Copy Markdown

This PR optimizes removeTrigger method.

Fixes issue # NA

Changes

  • removeTrigger method checks if there are more tiggers associated with a job every time when a trigger is being removed. Although SELECT COUNT is technically correct it will be always slower and need more IO versus the proposed change. The change reduces amount of IO which is important on Cloud based DB (aka RDS) as well as improve the performance if a job has a few thousands of triggers

Checklist

  • tested locally as well as under performance test using a real scenario
  • updated the docs - NA
  • added appropriate test - the change is covered by existing Unit and Integration tests
  • signed-off on the DCO referenced in the CONTRIBUTING link below via git commit -s on my commits, and submit this code under terms of the Apache 2.0 license and assign copyright to the Quartz project owners
    (If you're not using command-line, you can use a browser extension )

In submitting this contribution, I agree to the terms of contributing as referred to here:
https://github.com/quartz-scheduler/contributing/blob/main/CONTRIBUTING.md

Signed-off-by: Konstantin Kalin <konstantin.kalin@socotra.com>
@melloware

melloware commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

@kkalin68 i have never heard select count() was slower as most DB's like RDS are super optimized for this especially if selecting by an indexed field?

I see you are basically doing a "select TOP 1" query so it finds something immediately and exits.

@kkalin68

Copy link
Copy Markdown
Author

@kkalin68 i have never heard select count() was slower as most DB's like RDS are super optimized for this especially if selecting by an indexed field?

I see you are basically doing a "select TOP 1" query so it finds something immediately and exits.

It is not slower if you need to know the count. Here the count was used to see if any records exist and select count is overkill since it will do full index scan of all eligible records.

@melloware

Copy link
Copy Markdown
Contributor

absolutely i like it.

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