Add index on snippets type and id attributes
What does this MR do?
Adds a new index to the snippets table to help with count queries for usage data.
Some of the generated queries take more than 1s to finish so usually an index is added to optimize them.
See !32885 (merged)'s description for more details.
Relates to #215200 (closed)
Output from the migration
Up
VERBOSE=true bundle exec rake db:migrate:up VERSION=20200522235146
== 20200522235146 AddIndexOnSnippetTypeAndId: migrating =======================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:snippets, [:id, :type], {:algorithm=>:concurrently})
-> 0.0050s
-- add_index(:snippets, [:id, :type], {:algorithm=>:concurrently})
-> 0.0040s
== 20200522235146 AddIndexOnSnippetTypeAndId: migrated (0.0094s) ==============
Down
VERBOSE=true bundle exec rake db:migrate:down VERSION=20200522235146
== 20200522235146 AddIndexOnSnippetTypeAndId: reverting =======================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:snippets, [:id, :type], {:algorithm=>:concurrently})
-> 0.0059s
-- remove_index(:snippets, {:algorithm=>:concurrently, :column=>[:id, :type]})
-> 0.0086s
== 20200522235146 AddIndexOnSnippetTypeAndId: reverted (0.0149s) ==============
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖