fix: add index for `GetProvisionerLogsByIDBetween` (#5020)

This commit is contained in:
Colin Adler 2022-11-16 14:32:29 -06:00 committed by GitHub
parent da758ba712
commit e7f1192614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 8 deletions

View File

@ -624,6 +624,8 @@ CREATE UNIQUE INDEX idx_users_email ON users USING btree (email) WHERE (deleted
CREATE UNIQUE INDEX idx_users_username ON users USING btree (username) WHERE (deleted = false);
CREATE INDEX provisioner_job_logs_id_job_id_idx ON provisioner_job_logs USING btree (job_id, id);
CREATE UNIQUE INDEX templates_organization_id_name_idx ON templates USING btree (organization_id, lower((name)::text)) WHERE (deleted = false);
CREATE UNIQUE INDEX users_email_lower_idx ON users USING btree (lower(email)) WHERE (deleted = false);

View File

@ -0,0 +1 @@
DROP INDEX provisioner_job_logs_id_job_id_idx;

View File

@ -0,0 +1 @@
CREATE INDEX provisioner_job_logs_id_job_id_idx ON provisioner_job_logs USING btree (job_id, id ASC);

View File

@ -2370,7 +2370,7 @@ WHERE
AND (
id > $2
OR id < $3
) ORDER BY id
) ORDER BY id ASC
`
type GetProvisionerLogsByIDBetweenParams struct {
@ -2488,9 +2488,9 @@ WHERE
AND nested.completed_at IS NULL
AND nested.provisioner = ANY($3 :: provisioner_type [ ])
ORDER BY
nested.created_at FOR
UPDATE
SKIP LOCKED
nested.created_at
FOR UPDATE
SKIP LOCKED
LIMIT
1
) RETURNING id, created_at, updated_at, started_at, canceled_at, completed_at, error, organization_id, initiator_id, provisioner, storage_method, type, input, worker_id, file_id

View File

@ -8,7 +8,7 @@ WHERE
AND (
id > @created_after
OR id < @created_before
) ORDER BY id;
) ORDER BY id ASC;
-- name: InsertProvisionerJobLogs :many
INSERT INTO

View File

@ -23,9 +23,9 @@ WHERE
AND nested.completed_at IS NULL
AND nested.provisioner = ANY(@types :: provisioner_type [ ])
ORDER BY
nested.created_at FOR
UPDATE
SKIP LOCKED
nested.created_at
FOR UPDATE
SKIP LOCKED
LIMIT
1
) RETURNING *;