Create Index on Environments project_id, state, environment_type
What does this MR do?
Replace the index on the environments
table on project_id, state
with one on project_id, state, environment_type
.
This is from discussion in !19775 (merged).
See !19775 (comment 242656843)
Issue: #3713 (closed)
This index is meant to optimize the following query (and similar with different id's):
SELECT environments.* FROM (SELECT environments.*, rank() OVER (PARTITION BY project_id ORDER BY id DESC) FROM environments WHERE environments.environment_type IS NULL AND (environments.state IN ('available'::text))) environments WHERE (rank <= 3) AND environments.project_id IN (278964, 7764);
Produced by preloading this association:
has_many :environments_for_dashboard, -> { from(with_rank.unfoldered.available, :environments).where('rank <= 3') }, class_name: 'Environment'
Found in the Environment
model: !19775 (diffs)
Screenshots
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
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