|
45 | 45 | //! 2. [`ProjectionStatisticsProvider`] - column mapping through projections |
46 | 46 | //! 3. [`PassthroughStatisticsProvider`] - passthrough for cardinality-preserving operators |
47 | 47 | //! 4. [`AggregateStatisticsProvider`] - NDV-based GROUP BY cardinality estimation |
48 | | -//! 5. [`JoinStatisticsProvider`] - NDV-based join output estimation (hash, sort-merge, nested-loop, cross) |
| 48 | +//! 5. [`JoinStatisticsProvider`] - NDV-based join output estimation (hash, sort-merge, cross); nested-loop delegates to built-in |
49 | 49 | //! 6. [`LimitStatisticsProvider`] - caps output at the fetch limit (local and global) |
50 | 50 | //! 7. [`UnionStatisticsProvider`] - sums input row counts |
51 | 51 | //! 8. [`DefaultStatisticsProvider`] - fallback to `partition_statistics(None)` |
@@ -738,13 +738,16 @@ impl StatisticsProvider for AggregateStatisticsProvider { |
738 | 738 | } |
739 | 739 | } |
740 | 740 |
|
741 | | -/// Statistics provider for all join types (hash, sort-merge, nested-loop, cross). |
| 741 | +/// Statistics provider for equi-joins (hash join, sort-merge join) and cross joins. |
742 | 742 | /// |
743 | | -/// For equi-joins (hash join, sort-merge join), estimates output cardinality as |
| 743 | +/// For equi-joins, estimates output cardinality as |
744 | 744 | /// `left_rows * right_rows / product(max(left_ndv_i, right_ndv_i))` |
745 | 745 | /// across all join key columns (assuming independence between keys), |
746 | 746 | /// falling back to the Cartesian product when any key lacks NDV on both sides. |
747 | | -/// For nested-loop and cross joins, uses the exact Cartesian product. |
| 747 | +/// For cross joins, uses the exact Cartesian product. |
| 748 | +/// Nested-loop joins delegate to the built-in `partition_statistics` since an |
| 749 | +/// arbitrary `JoinFilter` can be highly selective and the Cartesian product |
| 750 | +/// would overestimate. |
748 | 751 | /// |
749 | 752 | /// The base inner-join estimate is then adjusted for the join type: |
750 | 753 | /// - Semi joins: capped at the preserved-side row count |
|
0 commit comments