Commit 0884f078 authored by Mike Kozono's avatar Mike Kozono

Add verification indexes for package files

For queries produced by these methods specifically:

- Packages::PackageFile.verification_pending_batch
- Packages::PackageFile.verification_failed_batch
- Packages::PackageFile.needs_verification_count

Since they are always running, at least every minute, and potentially
with high concurrency (depending on admin settings).
parent bbefa0f1
---
title: 'Geo: Add verification indexes for package files'
merge_request: 47372
author:
type: added
# frozen_string_literal: true
class AddVerificationIndexesForPackageFiles < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
PENDING_VERIFICATION_INDEX_NAME = "packages_packages_pending_verification"
FAILED_VERIFICATION_INDEX_NAME = "packages_packages_failed_verification"
NEEDS_VERIFICATION_INDEX_NAME = "packages_packages_needs_verification"
disable_ddl_transaction!
def up
add_concurrent_index :packages_package_files, :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
add_concurrent_index :packages_package_files, :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
add_concurrent_index :packages_package_files, :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
end
def down
remove_concurrent_index_by_name :packages_package_files, PENDING_VERIFICATION_INDEX_NAME
remove_concurrent_index_by_name :packages_package_files, FAILED_VERIFICATION_INDEX_NAME
remove_concurrent_index_by_name :packages_package_files, NEEDS_VERIFICATION_INDEX_NAME
end
end
418481f8281f8908740d3a8378b420f4d83853aab139b3401f7e410fc97d2488
\ No newline at end of file
...@@ -22741,6 +22741,12 @@ CREATE UNIQUE INDEX one_canonical_wiki_page_slug_per_metadata ON wiki_page_slugs ...@@ -22741,6 +22741,12 @@ CREATE UNIQUE INDEX one_canonical_wiki_page_slug_per_metadata ON wiki_page_slugs
CREATE INDEX package_name_index ON packages_packages USING btree (name); CREATE INDEX package_name_index ON packages_packages USING btree (name);
CREATE INDEX packages_packages_failed_verification ON packages_package_files USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
CREATE INDEX packages_packages_needs_verification ON packages_package_files USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3));
CREATE INDEX packages_packages_pending_verification ON packages_package_files USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0);
CREATE INDEX partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs ON ci_builds USING btree (scheduled_at) WHERE ((scheduled_at IS NOT NULL) AND ((type)::text = 'Ci::Build'::text) AND ((status)::text = 'scheduled'::text)); CREATE INDEX partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs ON ci_builds USING btree (scheduled_at) WHERE ((scheduled_at IS NOT NULL) AND ((type)::text = 'Ci::Build'::text) AND ((status)::text = 'scheduled'::text));
CREATE INDEX partial_index_deployments_for_legacy_successful_deployments ON deployments USING btree (id) WHERE ((finished_at IS NULL) AND (status = 2)); CREATE INDEX partial_index_deployments_for_legacy_successful_deployments ON deployments USING btree (id) WHERE ((finished_at IS NULL) AND (status = 2));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment