Skip to content

[Enhancement] SHOW TABLES on an external catalog initializes every table's metadata #66079

Closed

Description

@Baymine

Search before asking

  • I had searched in the issues and found no similar issues.

Description

SHOW TABLES against an external catalog iterates DatabaseIf.getTables(). For external databases this eagerly initializes every table through the meta cache — one getTableNullable() call, and therefore one remote metadata load, per table. For a catalog/database with many tables this turns a cheap name listing into N remote loads, making SHOW TABLES slow.

The verbose form SHOW FULL TABLES genuinely needs per-table information (Table_type, storage-format columns), but a plain SHOW TABLES only needs table names, which the catalog can already provide via getTableNamesOrEmptyWithLock() without loading any table object.

Solution

For the common case — a non-verbose SHOW TABLES on an external catalog — list the names directly via getTableNamesOrEmptyWithLock() instead of getTables(), so no table is initialized. The per-table SHOW privilege filter is preserved (it is name-based and needs no table load), so no table name is exposed to a user who lacks SHOW privilege on it.

SHOW FULL TABLES (verbose), SHOW VIEWS, SHOW STREAMS, and internal-catalog SHOW TABLES keep the existing getTables() path and are unaffected.

Use case

Faster SHOW TABLES on external (e.g. Hive/Iceberg) catalogs with many tables.

Related issues

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added a commit that references this issue on Jul 27, 2026
    0e95d71
  2. u70b3 commented on Aug 4, 2026

    @u70b3
    Contributor

    Hi @Baymine, this issue has been quiet for about two weeks, so I've gone ahead and implemented the fix you proposed: a non-verbose SHOW TABLES on an external catalog now lists table names via getTableNamesOrEmptyWithLock() instead of getTables(), while keeping the name-based SHOW privilege filter. SHOW FULL TABLES, SHOW VIEWS, SHOW STREAMS, and the internal catalog keep the existing path.

    I'll open a PR shortly with unit tests covering the new path. Happy to close it if you already have one in progress — just let me know.

  3. Baymine commented on Aug 4, 2026

    @Baymine
    ContributorAuthor

    Hi @Baymine, this issue has been quiet for about two weeks, so I've gone ahead and implemented the fix you proposed: a non-verbose SHOW TABLES on an external catalog now lists table names via getTableNamesOrEmptyWithLock() instead of getTables(), while keeping the name-based SHOW privilege filter. SHOW FULL TABLES, SHOW VIEWS, SHOW STREAMS, and the internal catalog keep the existing path.

    I'll open a PR shortly with unit tests covering the new path. Happy to close it if you already have one in progress — just let me know.

    Hi there, we are making progress with this pull request: #66080

  4. u70b3 commented on Aug 4, 2026

    @u70b3
    Contributor

    Ah, my mistake — I searched for related PRs before starting but missed #66080. Great to see this already in progress, and nice call using getTableNamesWithLock() over the OrEmpty variant — swallowing name-conflict/init failures into an empty result would have been a subtle regression vs. the old path.

    Since #66080 currently has manual testing only, I'd like to contribute the unit tests I wrote while implementing the same change independently (6 cases: names-only fast path never calls getTables(), LIKE filter, SHOW privilege filter, and SHOW FULL TABLES / SHOW VIEWS / internal-catalog paths unchanged). I'll open a PR against your branch with them shortly — feel free to fold them into #66080 if you like.

  5. added a commit that references this issue on Aug 4, 2026
    cad2f74
  6. added a commit that references this issue on Aug 11, 2026
    dcc2771
  7. added a commit that references this issue on Aug 17, 2026
    0ed97e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions