-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[WIP] Improve performance of querying system.jdbc.tables
for Hive, Iceberg, and Delta
#24110
base: master
Are you sure you want to change the base?
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
d2b86e4
to
e8bcc3f
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. Question: Should we consider setting the default value of "hive.metadata.parallelism" to 1 when using the "file" metastore?
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. Question: Is this resolution necessary? Could we instead use the existing mapping between ExtendedRelationType and RelationType that's already encapsulated in RelationType?
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.
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. |
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.
} | ||
} | ||
|
||
private RelationType resolveRelationType(TableInfo tableInfo) |
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
@@ -90,6 +90,7 @@ public class DeltaLakeConfig | |||
private boolean queryPartitionFilterRequired; | |||
private boolean deletionVectorsEnabled; | |||
private boolean deltaLogFileSystemCacheDisabled; | |||
private int metadataParallelism = 8; |
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.
8 seems pretty low. Did you test bigger number of threads?
@@ -176,6 +176,8 @@ public class HiveConfig | |||
|
|||
private S3StorageClassFilter s3StorageClassFilter = S3StorageClassFilter.READ_ALL; | |||
|
|||
private int metadataParallelism = 8; |
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?
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:
I'm marking this as a draft because there are a few questions included in commit messages that need to be addressed.
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.
( ) Release notes are required, with the following suggested text: