-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Improve performance of querying system.jdbc.tables for Hive, Iceberg, and Delta
#24110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
system.jdbc.tables for Hive, Iceberg, and Delta
|
Hi there! I came across this PR and was curious if it might address a similar issue to the one in my PR #23909, which focuses on improving the retrieval of column metadata for Iceberg tables. In my PR, I added parallelization to the streamTableColumns method in IcebergMetadata.java, enhancing performance for users pulling column metadata. I noticed there haven’t been any changes related to the REST catalog in this PR. Would you consider applying similar improvements to the REST catalog as well? This would allow users working with REST catalog setups to benefit from the enhanced metadata retrieval. Also, could you provide some details about the use cases this PR aims to support? Thanks! |
plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java
Outdated
Show resolved
Hide resolved
e8bcc3f to
f7f8579
Compare
This PR focuses on improving the performance of table listing. It won't address column retrieval, but it should be relatively straightforward to extend the current changes to include columns as well.
Currently, I'm mainly focused on improving performance for the Glue catalog, but the same approach can be applied to other catalogs as well.
The goal is to improve the performance of queries like the one in the PR's description, which are often issued by DB tools to list tables. |
lukasz-stec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, that will be a great improvement for glue catalogs with many schemas!.
Please provide benchmark results once you have it, both in PR description but also in the commit messages if applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@piotrrzysko I would drop the question from the commit message.
The question was:
Is this resolution necessary? Could we instead use the
existing mapping between ExtendedRelationType and RelationType that's
already encapsulated in RelationType?
I guess the question here is, is OTHER_VIEW or OTHER_MATERIALIZED_VIEW possible in delta-lake? TRINO_MATERIALIZED_VIEW is not.
@raunaqmorarka @dain Do you know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw it is ok for me to have the resolveRelationType here to keep the existing functionality
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would drop the question from the commit message.
The question is
Question: Should we consider setting the default value of
"hive.metadata.parallelism" to 1 when using the "file" metastore?
I would not worry about file metastore. @raunaqmorarka WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems super easy to do however (in the module set default config), but yes, I don't think it matters unless this change has affected test runtime for tests which use the FileHMS.
f7f8579 to
8f8bf88
Compare
system.jdbc.tables for Hive, Iceberg, and Delta system.jdbc.tables for Hive, Iceberg, and Delta
8f8bf88 to
39b23ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems super easy to do however (in the module set default config), but yes, I don't think it matters unless this change has affected test runtime for tests which use the FileHMS.
plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadataFactory.java
Outdated
Show resolved
Hide resolved
d6980ee to
a443d3f
Compare
|
/test-with-secrets sha=a443d3f9c7a936a810aac5f5b2b0a0e552f9beaf |
|
The CI workflow run with tests that require additional secrets finished as failure: https://github.com/trinodb/trino/actions/runs/11936682245 |
...ino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/IcebergGlueCatalogConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergModule.java
Outdated
Show resolved
Hide resolved
a443d3f to
535ac27
Compare
The parameter for specifying the maximum number of threads fetching
tables ("hive.metadata.parallelism") aligns with the naming convention
used in the BigQuery connector ("bigquery.metadata.parallelism").
Parallelization has been introduced in HiveMetadata rather than in
specific metastore implementations, primarily to avoid reintroducing a
cache storing tables for all schemas, which was removed in
trinodb@cb4d168.
This approach attempts to parallelize table retrieval for all metastore
types, even though not all support concurrent access. Currently, only
the FileHiveMetastore does not support multithreaded access, making
parallelization ineffective.
Benchmark results for the following query:
SELECT * FROM system.jdbc.tables WHERE table_cat = 'hive'
show decrease in execution time from 55s to 15s.
The queried catalog had 234 schemas with a total of 5674 tables.
Before introducing DeltaLakeMetadata::getRelationTypes, ConnectorMetadata::getRelationTypes was used to retrieve relation types for Delta Lake. The original implementation classified all tables as RelationType.TABLE, except those with the extended relational type TRINO_VIEW, which were classified as RelationType.VIEW. This is why the resolveRelationType method was added in this commit. Benchmark results for the following query: SELECT * FROM system.jdbc.tables WHERE table_cat = 'delta_lake' show decrease in execution time from 55s to 16s. The queried catalog had 234 schemas with a total of 5674 tables.
Parallelization has been implemented at the TrinoCatalog level, rather than in IcebergMetadata, because some catalogs (e.g., Nessie) seem to support optimized table retrieval across all schemas. Currently, parallelization has been added for Glue and Hive catalogs, but it can easily be extended to other catalogs as well. Benchmark results for the following query: SELECT * FROM system.jdbc.tables WHERE table_cat = 'iceberg' show decrease in execution time from 54s to 17s. The queried catalog had 234 schemas with a total of 5674 tables.
535ac27 to
c84ce62
Compare
|
Rebased and addressed comments. |
|
/test-with-secrets sha=c84ce622d138423d1d8cd51e7e34a2db3447eb33 |
|
The CI workflow run with tests that require additional secrets finished as failure: https://github.com/trinodb/trino/actions/runs/11973910005 |
|
unrelated failure on test with secrets, merging. Thanks a lot @piotrrzysko. 😄 🚀
|
|
@hashhar @raunaqmorarka @piotrrzysko - can you explain this more so we can get a release notes entry that is more user facing. What does it actually improve? Is this for federated queries where these connectors need to access jdbc info? Also .. is Hudi connector also affected? |
|
this improves metadata retreival performance when accessing the The proposed RN entry is indeed user-facing - people who were querying |

Description
For now, we are mainly focused on improving performance for connectors using Glue.
Locally, the execution time of the following query, for 6500 tables and 530 schemas, decreased from 3m 11s to 27s:
Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text: