Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix fetch job performance regression #1225

Merged
merged 2 commits into from
Oct 19, 2024

Conversation

onlyann
Copy link
Contributor

@onlyann onlyann commented Oct 19, 2024

This modifies indexes to improve performance of the fetch_job function.

Recently added features such as job priority and aborting jobs have introduced a performance regression.

It fixes that performance regression by updating an existing index and adding a new one so that the fetch_job function avoids sequential scans of the job table in both the outer and inner query.

It also contains an additional timing tweak to an acceptance test to make it less flaky

Successful PR Checklist:

  • Tests
    • (not applicable?)
  • Documentation
    • (not applicable?)

PR label(s):

@onlyann onlyann requested a review from a team as a code owner October 19, 2024 11:23
@github-actions github-actions bot added PR type: bugfix 🕵️ Contains bug fix PR type: miscellaneous 👾 Contains misc changes labels Oct 19, 2024
Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  procrastinate
  app.py
  blueprints.py
  builtin_tasks.py
  cli.py
  job_context.py
  jobs.py
  periodic.py
  psycopg_connector.py
  retry.py
  schema.py
  shell.py
  signals.py
  sync_psycopg_connector.py
  tasks.py
  procrastinate/contrib/aiopg
  aiopg_connector.py
  procrastinate/contrib/django
  apps.py
  django_connector.py
  healthchecks.py
  migrations_utils.py
  models.py
  settings.py
  procrastinate/contrib/django/management/commands
  procrastinate.py
  procrastinate/contrib/psycopg2
  psycopg2_connector.py
  procrastinate/contrib/sphinx
  __init__.py
  procrastinate/contrib/sqlalchemy
  psycopg2_connector.py
Project Total  

The report is truncated to 25 files out of 28. To see the full report, please visit the workflow summary page.

This report was generated by python-coverage-comment-action

@github-actions github-actions bot removed the PR type: miscellaneous 👾 Contains misc changes label Oct 19, 2024
@onlyann onlyann force-pushed the fetch-jobs-indexes branch from 382665b to c815369 Compare October 19, 2024 11:33
Copy link
Member

@ewjoachim ewjoachim left a comment

Choose a reason for hiding this comment

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

Seems awesome. Let's not forget to port this to v3.
Thank you for your quick reaction!

@@ -0,0 +1,7 @@
-- recreate procrastinate_jobs_id_lock_idx index by adding aborting status to the filter so that it can be used by the fetch job function
CREATE INDEX procrastinate_jobs_id_lock_idx_temp ON procrastinate_jobs (id, lock) WHERE status = ANY (ARRAY['todo'::procrastinate_job_status, 'doing'::procrastinate_job_status, 'aborting'::procrastinate_job_status]);
Copy link
Member

Choose a reason for hiding this comment

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

Note for self, don't forget to tell people in the release notes to create the index concurrently if applicable.

@ewjoachim ewjoachim merged commit 98fd11e into procrastinate-org:main Oct 19, 2024
11 checks passed
@ewjoachim
Copy link
Member

Released, and added some migration notes:
https://github.com/procrastinate-org/procrastinate/releases/tag/2.15.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
PR type: bugfix 🕵️ Contains bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants