Preferred write partitioning threshold#6920
Conversation
There was a problem hiding this comment.
To be honest I have no idea where to put it here, so it landed at the beginning.
There was a problem hiding this comment.
Move it before or after reorder joins is applied. The assumption is that for reorder joins we should have the most accurate stats:
PredicatePushDownhas been run withuseTableProperties- later in the planning exchange nodes are added which might confuse stats.
Please add a comment why there.
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
|
Docs still missing |
|
@skrzypo987 does this fix #6570 ? |
I am afraid if enabling |
d8962f2 to
e896ea3
Compare
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/plan/TableWriterNode.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/sql/planner/TestInsert.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/sql/planner/TestInsert.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/sql/planner/TestInsert.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/sql/planner/TestInsert.java
Outdated
Show resolved
Hide resolved
e896ea3 to
7c5beac
Compare
|
I noticed that |
7c5beac to
b1b1c3a
Compare
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
b1b1c3a to
9a65ec1
Compare
There was a problem hiding this comment.
Would it be possible to make the configuration toggle a little bit automatic?
I.e. how is the user going to determine whether they want to set this?
If this depends e.g. on number of partitions vs number of nodes, we could encode this reasoning within server's logic
There was a problem hiding this comment.
The idea was to leave it backward-compatible (0 as the default value) and let the user decide the threshold based on his/her workload if necessary.
However making this more "intelligent" is not a bad idea. The question is whether we want to do it here or as a follow-up.
There was a problem hiding this comment.
when number of written or when the number of written? I'm not native, but I think the latter is correct
There was a problem hiding this comment.
If this depends e.g. on number of partitions vs number of nodes, we could encode this reasoning within server's logic
This doesn't really depend on number of workers. The hard limit is hive.max-partitions-per-writers which is independent of workers.
7cc4119 to
929feb6
Compare
There was a problem hiding this comment.
when number of written or when the number of written? I'm not native, but I think the latter is correct
There was a problem hiding this comment.
If this depends e.g. on number of partitions vs number of nodes, we could encode this reasoning within server's logic
This doesn't really depend on number of workers. The hard limit is hive.max-partitions-per-writers which is independent of workers.
There was a problem hiding this comment.
I suggest to set it to some default value, e.g: 50. This should:
- make preferred partitioning to be used when there is full table CTAS with more than 50 partitions
- provide good concurrency (>50) for preferred partitioning
- mitigate hive writer partition limit (100)
- provide good concurrency for inserts into single partition
WDYT: @findepi @willmostly ?
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
Nope. Both should be documented. |
6d5fd05 to
3246266
Compare
|
Added docs and updated the code.
|
core/trino-main/src/test/java/io/trino/sql/planner/TestInsert.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
mechansm -> optimization
Elaborate more what partitions it refers to.
There was a problem hiding this comment.
Make sure it's possible to force preferred partitioning even when stats are missing (e.g when threshold is set to <=1).
When stats are missing and threshold is >1, we should fallback to not use preferred partitioning (previous default).
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
we should also enable use-preferred-write-partitioning by default (separate commit).
Maybe we should also rename that property to use-automatic-preferred-write-partitioning and mark the old one as legacy since the previous behavior is changing. wdyt @findepi ?
3246266 to
3f150ee
Compare
|
Another version. |
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Maybe a follow-up commit? Features and docs should IMO be added atomically.
There was a problem hiding this comment.
if the number of partitions cannot be estimated or preferred-write-partitioning-min-number-of-partitions > 1 then preferred write partitioning won't be used. Setting preferred-write-partitioning-min-number-of-partitions to value less or equal to 1 will force Trino to use preferrered write partitioning
There was a problem hiding this comment.
or preferred-write-partitioning-min-number-of-partitions > 1 then preferred write partitioning won't be used means that setting this value > 1 will always disable the feature. And this is not the case.
Let's wait for @mosabua to comment on that.
I understand it that if estimated number of partitions >= min threshold, we use preferred write partitioning. |
3f150ee to
cc07a51
Compare
core/trino-main/src/main/java/io/trino/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
cc07a51 to
ba2906a
Compare
core/trino-main/src/main/java/io/trino/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/sql/planner/TestInsert.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/sql/planner/TestInsert.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
testCreateTableAsSelectUnpartitioned should use withPreferredPartitioning. Please extract as a separate commit
...rino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPreferWritePartitioning.java
Outdated
Show resolved
Hide resolved
ba2906a to
8cccfac
Compare
sopel39
left a comment
There was a problem hiding this comment.
lgtm % comment about rule placing, let's enable preferred partitioning by default
There was a problem hiding this comment.
Move it before or after reorder joins is applied. The assumption is that for reorder joins we should have the most accurate stats:
PredicatePushDownhas been run withuseTableProperties- later in the planning exchange nodes are added which might confuse stats.
Please add a comment why there.
core/trino-main/src/main/java/io/trino/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
Make 'CreateTableAsSelectUnpartitioned' test use preferred partitioning
8cccfac to
c787f46
Compare
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
Trino will enable preferred write partitioning only when estimated number of partitions is lower than preferred_write_partitioning_min_number_of_partitions
c787f46 to
65db157
Compare
|
|
||
| // Prefer write partitioning rule requires accurate stats. | ||
| // Therefore PredicatePushDown, columnPruningOptimizer and | ||
| // RemoveRedundantIdentityProjections need to run beforehand. |
There was a problem hiding this comment.
nit: we could remove RemoveRedundantIdentityProjections from both comments (here and below) as it should not affect stats. This could be separate PR
There was a problem hiding this comment.
I'll handle it when I get some free cycles
No description provided.