Hi all,
I have a question about the calculation of selectivity.
I see the following code in set_rest_selec() in clausesel.c.
cost_clause = clausenode->selectivity;
/* * Check to see if the selectivity of this clause or any
'or' * subclauses (if any) haven't been set yet. */ if (cost_clause <= 0 ||
valid_or_clause(clausenode)) {
Why is valid_or_clause(clausenode) necessary ?
This means that even if selectivity is set,set_rest_selec()
calls compute_clause_selec() if the target clause is a
valid_or_clause.
compute_clause_selec() would add the selectivity of
elements of or_clause to the current selectivity.
AFAIC,compute_clause_selec() is called twice at least ( from add_restrict_and_join_to_rel() in initsplan.c and
set_rest_selec()in clausesel.c)
and seems to accumulate the result by repetition if
the target clause is a valid_or_clause.
Regards.
Hiroshi Inoue
Inoue@tpf.co.jp