HIVE-29740 : Fix SHOW TABLES operation taking 300 seconds+ on very large databases#6610
Open
vikramahuja1001 wants to merge 1 commit into
Open
Conversation
|
Contributor
Author
|
@deniskuzZ / @ayushtkn / @dengzhhu653 / @zabetak / @saihemanth-cloudera Can you help to review this PR? Thanks. |
a3602bb to
9c7ddc7
Compare
| * separate-thread execution, which breaks Mockito's ThreadLocal-based MockedStatic. | ||
| */ | ||
| @Test | ||
| public void testFilterTables_performance_100kTables() throws Exception { |
Contributor
There was a problem hiding this comment.
nit: a hard 5s wall-clock assert can be unstable on slow/shared runners. Consider adding @Category(SlowTests.class)
Contributor
Author
There was a problem hiding this comment.
Will handle it as a part of a follow up JIRA if that's okay since it is a reasonable scope for a separate JIRA itself?
9c7ddc7 to
3594b2b
Compare
3594b2b to
770f65d
Compare
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.



What changes were proposed in this pull request?
This PR optimizes AuthorizationMetaStoreFilterHook.filterTables() by replacing the existing O(n²) nested-loop cartesian-product implementation with a sort + binary search filtering.
Why are the changes needed?
On very large databases, SHOW TABLES can become extremely slow because filterTables() performs a nested search between the authorized objects and the table list.
With 100,000 tables, the previous implementation performs on the order of 10 billion comparisons, causing execution times of 200–300 seconds.
The new implementation reduces the lookup complexity while preserving the existing authorization semantics, reducing execution time to well under 5 seconds in the included performance test.
Does this PR introduce any user-facing change?
Users running commands such as SHOW TABLES on very large databases should observe a significant reduction in execution time. There are no functional or behavioral changes to authorization or query results; only the performance of table filtering is improved.
How was this patch tested?
Tested with 100,000 tables