-
Notifications
You must be signed in to change notification settings - Fork 899
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
Conversation
coderd/database/querier_test.go
Outdated
"github.com/coder/coder/v2/coderd/provisionerdserver" | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Use only
online provisioner daemons
forGetProvisionerJobsByIDsWithQueuePosition
query. It should improve performance of the query.