-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Improve stats for join side determination (#3655)
This PR updates swordfish join side determination logic to compare num rows instead of upper bound size bytes. ### Details: - Use a fixed `num_rows` and `size_bytes` in the `ApproxStats` instead of lower / upper bounds. - Instead of having a fixed 20% selectivity for filters, take into account the complexity of the filter expressions into the selectivity. E.g. `ANDS` will be more selective than `ORS`, and `IS_NULL` will generally be less selective than comparisons or equalities. (This is useful because all of our joins have null filter pushdowns, but it tends to be the case that the side with the more complex filters will be the better side for the hash table, and having a fixed 20% selectivity will miss out on this) ### Results on TPCH SF10: | Query | Original (ms) | Latest (ms) | Change (%) | |-------|--------------|-------------|------------| | Q1 | 493.39 | 500.53 | +1.45% | | Q2 | 158.53 | 149.09 | -5.95% | | Q3 | 499.76 | 490.63 | -1.83% | | Q4 | 2527.00 | 269.22 | -89.34% | | Q5 | 757.68 | 721.30 | -4.80% | | Q6 | 151.95 | 156.64 | +3.09% | | Q7 | 471.33 | 458.81 | -2.66% | | Q8 | 568.80 | 1519.60 | +167.16% | | Q9 | 3644.70 | 3572.20 | -1.99% | | Q10 | 752.60 | 722.10 | -4.05% | | Q11 | 238.79 | 223.87 | -6.25% | | Q12 | 2676.30 | 320.82 | -88.01% | | Q13 | 979.72 | 962.65 | -1.74% | | Q14 | 510.17 | 504.23 | -1.16% | | Q15 | 480.39 | 468.77 | -2.42% | | Q16 | 183.70 | 188.36 | +2.54% | | Q17 | 392.50 | 375.32 | -4.38% | | Q18 | 7706.50 | 855.50 | -88.90% | | Q19 | 955.58 | 977.44 | +2.29% | | Q20 | 458.89 | 1191.30 | +159.61% | | Q21 | 10236.90 | 9616.3 | -6.06% | | Q22 | 2188.00 | 186.51 | -91.47% | Total time: - Before: 36.03s - After: 24.36s ### Notes: - Q8 and Q20 now have regressions. This is because cardinality estimation for joins is not accurate (it assumes primary key / foreign key join), leading to wrong probe side decisions for subsequent joins. --------- Co-authored-by: Colin Ho <colinho@Colins-MBP.localdomain>
- Loading branch information
Showing
19 changed files
with
243 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.