Skip to content

Commit

Permalink
fix(metastore): add index to support index name wildcard expansion
Browse files Browse the repository at this point in the history
The sql that is generated to expand an index name (index_id) into all of
the matching index names uses the LIKE clause to do partial text
matches. However, the only index on the index_id column utilizes the
default btree configuration which can only do exact value comparisons.
In environments with a large search volume over many thousands of
indexes, this can be a bottle neck as the query will always do an full
table scan. This drops and recreates the unique index on index_id
to include the `varchar_pattern_ops` which allows for wildcard
matching on a varchar column using the LIKE operator

Fixes: #5437
  • Loading branch information
esatterwhite committed Sep 18, 2024
1 parent 98328db commit d9f2fc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP INDEX IF EXISTS IF EXISTS indexes_index_id_unique;
ALTER TABLE indexes ADD CONSTRAINT indexes_index_id_unique UNIQUE (index_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE indexes DROP CONSTRAINT IF EXISTS indexes_index_id_unique;

CREATE UNIQUE INDEX IF NOT EXISTS indexes_index_id_unique
ON indexes USING btree ("index_id" varchar_pattern_ops);

0 comments on commit d9f2fc4

Please sign in to comment.