-
Notifications
You must be signed in to change notification settings - Fork 3
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
Check for duplicate indexes #42
Comments
This query will check for exactly the same set of columns as keys: SELECT indrelid::regclass as relation,
a.indexrelid::regclass as index1,
b.indexrelid::regclass as index2
FROM pg_index a JOIN pg_index b USING (indrelid, indkey)
WHERE a.indexrelid != b.indexrelid; It might be interesting to check if one index is redundant in the sense that there is another index that has the same set of initial columns. Something like: CREATE TABLE foo (a int, b int, c int);
CREATE INDEX ON foo(a,b);
CREATE INDEX ON foo(a,b,c); There seems to be a few customer cases with this kind of situation, especially if the customer creates a covering index but forget to remove the old index. |
mkindahl
added a commit
to mkindahl/doctor
that referenced
this issue
Jan 29, 2024
Add rule to check for duplicate indexes. Two indexes are duplicates if they have different relation OID and are indexes for the same relation and has *exactly* the same list of keys in the same order. Note that we are not checking if an index is redundant (if one index has a set of key columns that is a prefix of the other). Complete timescale#42
mkindahl
added a commit
to mkindahl/doctor
that referenced
this issue
Jan 29, 2024
Add rule to check for duplicate indexes. Two indexes are duplicates if they have different relation OID and are indexes for the same relation and has *exactly* the same list of keys in the same order. Note that we are not checking if an index is redundant (if one index has a set of key columns that is a prefix of the other). Complete timescale#42
mkindahl
added a commit
to mkindahl/doctor
that referenced
this issue
Jan 29, 2024
Add rule to check for duplicate indexes. Two indexes are duplicates if they have different relation OID and are indexes for the same relation and has *exactly* the same list of keys in the same order. Note that we are not checking if an index is redundant (if one index has a set of key columns that is a prefix of the other). Complete timescale#42
mkindahl
added a commit
to mkindahl/doctor
that referenced
this issue
Jan 29, 2024
Add rule to check for duplicate indexes. Two indexes are duplicates if they have different relation OID and are indexes for the same relation and has *exactly* the same list of keys in the same order. Note that we are not checking if an index is redundant (if one index has a set of key columns that is a prefix of the other). Complete timescale#42
mkindahl
added a commit
to mkindahl/doctor
that referenced
this issue
Jan 29, 2024
Add rule to check for duplicate indexes. Two indexes are duplicates if they have different relation OID and are indexes for the same relation and has *exactly* the same list of keys in the same order. Note that we are not checking if an index is redundant (if one index has a set of key columns that is a prefix of the other). Resolves timescale#42
mkindahl
added a commit
that referenced
this issue
Feb 5, 2024
Add rule to check for duplicate indexes. Two indexes are duplicates if they have different relation OID and are indexes for the same relation and has *exactly* the same list of keys in the same order. Note that we are not checking if an index is redundant (if one index has a set of key columns that is a prefix of the other). Resolves #42
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check if there are duplicate indexes for a table, that is, two different indexes that are for the same relation and have the same set of key columns.
The text was updated successfully, but these errors were encountered: