Skip to content

HIVE-29740 : Fix SHOW TABLES operation taking 300 seconds+ on very large databases#6610

Open
vikramahuja1001 wants to merge 1 commit into
apache:masterfrom
vikramahuja1001:HIVE-29740_Optimize_Show_Tables
Open

HIVE-29740 : Fix SHOW TABLES operation taking 300 seconds+ on very large databases#6610
vikramahuja1001 wants to merge 1 commit into
apache:masterfrom
vikramahuja1001:HIVE-29740_Optimize_Show_Tables

Conversation

@vikramahuja1001

@vikramahuja1001 vikramahuja1001 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@sonarqubecloud

Copy link
Copy Markdown

@vikramahuja1001

vikramahuja1001 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@deniskuzZ / @ayushtkn / @dengzhhu653 / @zabetak / @saihemanth-cloudera Can you help to review this PR? Thanks.

* separate-thread execution, which breaks Mockito's ThreadLocal-based MockedStatic.
*/
@Test
public void testFilterTables_performance_100kTables() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a hard 5s wall-clock assert can be unstable on slow/shared runners. Consider adding @Category(SlowTests.class)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@vikramahuja1001 vikramahuja1001 force-pushed the HIVE-29740_Optimize_Show_Tables branch from 9c7ddc7 to 3594b2b Compare July 16, 2026 19:18
@vikramahuja1001 vikramahuja1001 force-pushed the HIVE-29740_Optimize_Show_Tables branch from 3594b2b to 770f65d Compare July 16, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants