File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 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
389389</programlisting>
390390
391391 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):
395396
396397<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 )
398399 = (1 - 0) * (1 - 0) / max(10000, 10000)
399400 = 0.0001
400401</programlisting>
401402
402403 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).
404406 The number of rows
405407 that the join is likely to emit is calculated as the cardinality of the
406408 Cartesian product of the two inputs, multiplied by the
You can’t perform that action at this time.
0 commit comments