Skip to content

fix: optimize queue position sql query #17974

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

Merged
merged 4 commits into from
May 28, 2025

Conversation

evgeniy-scherbina
Copy link
Contributor

@evgeniy-scherbina evgeniy-scherbina commented May 21, 2025

Use only online provisioner daemons for GetProvisionerJobsByIDsWithQueuePosition query. It should improve performance of the query.

@evgeniy-scherbina evgeniy-scherbina marked this pull request as ready for review May 21, 2025 17:30
Comment on lines 12 to 13
"github.com/coder/coder/v2/coderd/provisionerdserver"

Copy link
Member

Choose a reason for hiding this comment

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

This should be grouped with the rest of the github.com/coder/coder/v2 imports. Also, the cdr.dev/slog import should be grouped in with those as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -80,17 +80,21 @@ pending_jobs AS (
WHERE
job_status = 'pending'
),
online_provisioner_daemons AS (
SELECT id, tags FROM provisioner_daemons pd
WHERE pd.last_seen_at IS NOT NULL AND pd.last_seen_at >= (NOW() - (@stale_interval_ms::bigint || ' ms')::interval)
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be a more descriptive param like provisioner_daemon_stale_interval_ms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use @stale_interval_ms everywhere - so I kept it for consistency.

@evgeniy-scherbina evgeniy-scherbina merged commit 110102a into main May 28, 2025
35 checks passed
@evgeniy-scherbina evgeniy-scherbina deleted the yevhenii/optimize-sql-query branch May 28, 2025 12:21
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants