Skip to content

Improve catalog show tables query#94467

Merged
SmitaRKulkarni merged 16 commits intomasterfrom
Improve_catalog_show_tables
Feb 12, 2026
Merged

Improve catalog show tables query#94467
SmitaRKulkarni merged 16 commits intomasterfrom
Improve_catalog_show_tables

Conversation

@SmitaRKulkarni
Copy link
Copy Markdown
Member

@SmitaRKulkarni SmitaRKulkarni commented Jan 16, 2026

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Improved processing 'show tables' query by fetching only names of tables and improved getLightweightTablesIterator to return structure containing only table names. resolves #93835

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@SmitaRKulkarni SmitaRKulkarni marked this pull request as draft January 16, 2026 23:03
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jan 16, 2026

Workflow [PR], commit [5d8e412]

Summary:

job_name test_name status info comment
Performance Comparison (amd_release, master_head, 4/6) failure
Check Results failure IGNORED

@clickhouse-gh clickhouse-gh bot added the pr-improvement Pull request with some product improvements label Jan 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the performance of SHOW TABLES queries by optimizing how table metadata is fetched. Instead of loading full table objects, the code now returns lightweight table details (just table names) when only basic information is needed.

Changes:

  • Modified getLightweightTablesIterator() to return a vector of LightWeightTableDetails structs instead of a full iterator with table objects
  • Added a new showTablesQuery() method in TablesBlockSource that uses the lightweight iterator for queries that only need table names
  • Replaced all getLightweightTablesIterator() calls with getTablesIterator() except in the optimized SHOW TABLES path

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Databases/IDatabase.h Changed getLightweightTablesIterator() signature to return a vector of lightweight table details instead of an iterator
src/Databases/DataLake/DatabaseDataLake.h Updated method signature to match the new interface
src/Databases/DataLake/DatabaseDataLake.cpp Simplified implementation to return only table names without loading full table objects or thread pool operations
src/Storages/System/StorageSystemTables.cpp Added showTablesQuery() optimization and removed database-specific logic from needTable()
src/Storages/System/StorageSystemIcebergHistory.cpp Changed to use getTablesIterator() since full table objects are needed
src/Storages/System/StorageSystemCompletions.cpp Changed to use getTablesIterator() since full table objects are needed
src/Storages/System/StorageSystemColumns.cpp Changed to use getTablesIterator() since full table objects are needed
src/Interpreters/InterpreterSystemQuery.cpp Changed to use getTablesIterator() since full table objects are needed

@SmitaRKulkarni SmitaRKulkarni marked this pull request as ready for review January 19, 2026 22:21
@alesapin alesapin self-assigned this Jan 23, 2026

if (!tables_it || !tables_it->isValid())
tables_it = database->getLightweightTablesIterator(context,
tables_it = database->getTablesIterator(context,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So now if any exception is thrown from catalog it will be thrown here. Let's move try/catch logic into getTablesIterator as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think you mean for DatabaseDataLake, then yes try catch added in getTablesIterator

Copy link
Copy Markdown
Member

@alesapin alesapin left a comment

Choose a reason for hiding this comment

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

We need to have a test which will show the perf improvement. Please introduce a fail point into tryGetTableImpl which will artificially slow down it (add sleep). Write an integration test with any catalog and check that SHOW TABLES is not affected by this sleep.

@SmitaRKulkarni SmitaRKulkarni added this pull request to the merge queue Feb 12, 2026
Merged via the queue into master with commit 8a4b44c Feb 12, 2026
132 of 134 checks passed
@SmitaRKulkarni SmitaRKulkarni deleted the Improve_catalog_show_tables branch February 12, 2026 14:42
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 12, 2026
mkmkme pushed a commit to Altinity/ClickHouse that referenced this pull request Mar 18, 2026
…how_tables

Improve catalog show tables query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do less requests for SHOW TABLES query in DataLakeCatalog

5 participants