File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -389,18 +389,20 @@ tablename | null_frac | n_distinct | most_common_vals
389
389
</programlisting>
390
390
391
391
In this case there is no <acronym>MCV</acronym> information for
392
- <structfield>unique2</structfield> because all the values appear to be
393
- unique, so we use an algorithm that relies only on the number of
394
- distinct values for both relations together with their null fractions:
392
+ <structname>unique2</structname> and all the values appear to be
393
+ unique (n_distinct = -1), so we use an algorithm that relies on the row
394
+ count estimates for both relations (num_rows, not shown, but "tenk")
395
+ together with the column null fractions (zero for both):
395
396
396
397
<programlisting>
397
- selectivity = (1 - null_frac1) * (1 - null_frac2) * min(1/num_distinct1, 1/num_distinct2 )
398
+ selectivity = (1 - null_frac1) * (1 - null_frac2) / max(num_rows1, num_rows2 )
398
399
= (1 - 0) * (1 - 0) / max(10000, 10000)
399
400
= 0.0001
400
401
</programlisting>
401
402
402
403
This is, subtract the null fraction from one for each of the relations,
403
- and divide by the maximum of the numbers of distinct values.
404
+ and divide by the row count of the larger relation (this value does get
405
+ scaled in the non-unique case).
404
406
The number of rows
405
407
that the join is likely to emit is calculated as the cardinality of the
406
408
Cartesian product of the two inputs, multiplied by the
You can’t perform that action at this time.
0 commit comments