Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple unique keys reported as "redundant indexes" by skeema lint #152

Closed
jearle-dealnews opened this issue Dec 14, 2020 · 4 comments
Closed
Labels

Comments

@jearle-dealnews
Copy link

Having the following example table:

CREATE TABLE `sample_table` (
    `sample_table_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `reference_table_one_id` bigint(20) unsigned NOT NULL,
    `reference_table_two_id` bigint(20) unsigned NOT NULL,
    `reference_table_three_id` bigint(20) unsigned NOT NULL,
    `reference_table_four_id` bigint(20) unsigned NOT NULL,
    PRIMARY KEY (`sample_table_id`),
    UNIQUE KEY `reference_table_one_id` (`reference_table_one_id`,`reference_table_two_id`,`reference_table_three_id`,`reference_table_four_id`),
    UNIQUE KEY `reference_table_one_id_2` (`reference_table_one_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

When I run skeema lint, I receive the following message:

Index reference_table_one_id_2 of table sample_table is redundant to larger index reference_table_one_id.

The intended purpose of these two unique keys is to constrain those columns to have unique values and therefore are not really redundant.

Is it possible for skeema to know the difference in index uses when doing this check? I am aware of the setting lint-dupe-index and that I can use it to ignore these messages, but lint-dupe-index is a useful check and has caught some redundant indexes that we have ended up dropping. I would prefer to not set it to ignore.

@evanelias
Copy link
Contributor

Thank you for the issue report! You're absolutely correct, unique indexes should not be considered redundant in this situation. I'll commit a fix soon.

@evanelias evanelias added the bug label Dec 14, 2020
@jearle-dealnews
Copy link
Author

Thank you

@evanelias
Copy link
Contributor

A fix has been committed to the main branch here for the Skeema CLI, and will be included in the next binary release, likely in ~early January. This fix has also been deployed to Skeema Cloud Linter today. Thanks again for the bug report!

@evanelias
Copy link
Contributor

This fix has been included in Skeema CLI v1.4.7, released today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants