Commit 6cbc7dd2 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'da-find-unsynced-job-artifacts-query' into 'master'

Geo - Improve the query performance to find unsynced job artifacts

See merge request gitlab-org/gitlab-ee!5350
parents 7716b5df 0f6f1dc1
...@@ -141,7 +141,7 @@ module Geo ...@@ -141,7 +141,7 @@ module Geo
fdw_job_artifacts.joins("LEFT OUTER JOIN job_artifact_registry fdw_job_artifacts.joins("LEFT OUTER JOIN job_artifact_registry
ON job_artifact_registry.artifact_id = #{fdw_job_artifacts_table}.id") ON job_artifact_registry.artifact_id = #{fdw_job_artifacts_table}.id")
.with_files_stored_locally .with_files_stored_locally
.where(job_artifact_registry: { id: nil }) .where(job_artifact_registry: { artifact_id: nil })
.where.not(id: except_artifact_ids) .where.not(id: except_artifact_ids)
end end
......
---
title: Geo - Improve the query performance to find unsynced job artifacts
merge_request: 5350
author:
type: performance
class AddIndexToArtifactIdOnJobArtifactRegistry < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :job_artifact_registry, :artifact_id
end
def down
if index_exists?(:job_artifact_registry, :artifact_id)
remove_concurrent_index :job_artifact_registry_finder, :artifact_id
end
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180405074130) do ActiveRecord::Schema.define(version: 20180412213305) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20180405074130) do ...@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20180405074130) do
t.boolean "missing_on_primary", default: false, null: false t.boolean "missing_on_primary", default: false, null: false
end end
add_index "job_artifact_registry", ["artifact_id"], name: "index_job_artifact_registry_on_artifact_id", using: :btree
add_index "job_artifact_registry", ["retry_at"], name: "index_job_artifact_registry_on_retry_at", using: :btree add_index "job_artifact_registry", ["retry_at"], name: "index_job_artifact_registry_on_retry_at", using: :btree
add_index "job_artifact_registry", ["success"], name: "index_job_artifact_registry_on_success", using: :btree add_index "job_artifact_registry", ["success"], name: "index_job_artifact_registry_on_success", using: :btree
......
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