Skip to content
Snippets Groups Projects

Add index for selecting active agent tokens

Merged Tiger Watson requested to merge index-cluster-agent-tokens-on-status into master
All threads resolved!

What does this MR do and why?

Adds a new index to cluster_agent_tokens to optimise querying the recently added status field.

Screenshots or screen recordings

== 20220111023852 IndexClusterAgentTokensOnStatus: migrating ==================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:cluster_agent_tokens, "agent_id, status, last_used_at DESC NULLS LAST", {:name=>"index_cluster_agent_tokens_on_agent_id_status_last_used_at", :algorithm=>:concurrently})
   -> 0.0160s
-- execute("SET statement_timeout TO 0")
   -> 0.0009s
-- add_index(:cluster_agent_tokens, "agent_id, status, last_used_at DESC NULLS LAST", {:name=>"index_cluster_agent_tokens_on_agent_id_status_last_used_at", :algorithm=>:concurrently})
   -> 0.0057s
-- execute("RESET statement_timeout")
   -> 0.0007s
== 20220111023852 IndexClusterAgentTokensOnStatus: migrated (0.0257s) =========
== 20220111023852 IndexClusterAgentTokensOnStatus: reverting ==================
-- transaction_open?()
   -> 0.0000s
-- indexes(:cluster_agent_tokens)
   -> 0.0041s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- remove_index(:cluster_agent_tokens, {:algorithm=>:concurrently, :name=>"index_cluster_agent_tokens_on_agent_id_status_last_used_at"})
   -> 0.0071s
-- execute("RESET statement_timeout")
   -> 0.0008s
== 20220111023852 IndexClusterAgentTokensOnStatus: reverted (0.0151s) =========

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

#348386 (closed)

Edited by Mayra Cabrera

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • mentioned in issue #348386 (closed)

  • Mehmet Emin INAC approved this merge request

    approved this merge request

  • Mehmet Emin INAC requested review from @mayra-cabrera and removed review request for @minac

    requested review from @mayra-cabrera and removed review request for @minac

  • :wave: @minac, thanks for approving this merge request.

    This is the first time the merge request is approved. To ensure full test coverage, a new pipeline has been started.

    For more info, please refer to the following links:

  • Tiger Watson changed the description

    changed the description

  • Setting label(s) ~"devops::configure" sectionops based on ~"group::configure".

  • Database migrations

    Migrations included in this change have been executed on gitlab.com data for testing purposes. For details, please see the migration testing pipeline (limited access).

    Migration Type Total runtime Result DB size change
    20220111023852 - IndexClusterAgentTokensOnStatus Post deploy 1.8 s :white_check_mark: +104.00 KiB
    Runtime Histogram for all migrations
    Query Runtime Count
    0 seconds - 0.01 seconds 0
    0.01 seconds - 0.1 seconds 3
    0.1 seconds - 1 second 0
    1 second - 5 minutes 0
    5 minutes + 0

    Migration: 20220111023852 - IndexClusterAgentTokensOnStatus

    • Type: Post deploy
    • Duration: 1.8 s
    • Database size change: +104.00 KiB
    Query Calls Total Time Max Time Mean Time Rows
    CREATE INDEX CONCURRENTLY "index_cluster_agent_tokens_on_agent_id_status_last_used_at" ON "cluster_agent_tokens" (agent_id, status, last_used_at DESC NULLS LAST) /*application:test,db_config_name:main*/
    1 11.2 ms 11.2 ms 11.2 ms 0
    SELECT "feature_gates".*
    FROM "feature_gates"
    WHERE "feature_gates"."feature_key" = $1 /*application:test,db_config_name:main*/
    1 1.7 ms 1.7 ms 1.7 ms 1
    SELECT "postgres_async_indexes".*
    FROM "postgres_async_indexes"
    WHERE "postgres_async_indexes"."name" = $1
    LIMIT $2 /*application:test,db_config_name:main*/
    1 0.1 ms 0.1 ms 0.1 ms 0
    Histogram for IndexClusterAgentTokensOnStatus
    Query Runtime Count
    0 seconds - 0.01 seconds 0
    0.01 seconds - 0.1 seconds 3
    0.1 seconds - 1 second 0
    1 second - 5 minutes 0
    5 minutes + 0

    Other migrations pending on GitLab.com
    Migration Type Total runtime Result DB size change

    Clone Details

    Clone ID Clone Created At Clone Data Timestamp Expected Removal Time
    database-testing-984646 2022-01-12 21:53:51 UTC 2022-01-12 19:25:43 UTC 2022-01-13 09:54:55 +0000

    Artifacts


    Brought to you by gitlab-org/database-team/gitlab-com-database-testing. Epic

  • Mayra Cabrera approved this merge request

    approved this merge request

  • Mayra Cabrera changed the description

    changed the description

  • Mayra Cabrera resolved all threads

    resolved all threads

  • Mayra Cabrera enabled an automatic merge when the pipeline for 89b341bf succeeds

    enabled an automatic merge when the pipeline for 89b341bf succeeds

  • added databaseapproved label and removed databasereviewed label

  • Thanks @tigerwnz! This LGTM from database. MWPS set :rocket:

  • merged

  • Mayra Cabrera mentioned in commit 9eddfadc

    mentioned in commit 9eddfadc

  • added workflowcanary label and removed workflowstaging label

  • added workflowproduction label and removed workflowcanary label

  • Tiger Watson mentioned in merge request !78348 (merged)

    mentioned in merge request !78348 (merged)

  • Please register or sign in to reply
    Loading