Drop redundant unique index on snprc_ehr.labwork_services.ServiceId - #976
Merged
Merged
Conversation
labkey-martyp
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
snprc_ehr.labwork_services declares PRIMARY KEY (ServiceId) and then creates idx_labwork_services_serviceid, a UNIQUE index on that same column. The primary key's B-tree already enforces the identical uniqueness guarantee and serves the same queries, so the second index costs write throughput and storage while buying nothing. ToolsController$TestCase.testOverlappingIndices fails on PostgreSQL because of it.
The index dates to 2017, when the table's primary key was changed to ServiceId. It only became visible to this test after PostgreSQL support was added to the SNPRC modules, since the test is gated on isPostgreSQL().
Related Pull Requests
Changes