selectivity calculation for or_clause is wrong ? - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject selectivity calculation for or_clause is wrong ?
Date
Msg-id 000401bed261$965d2520$2801007e@cadzone.tpf.co.jp
Whole thread Raw
Responses Re: [HACKERS] selectivity calculation for or_clause is wrong ?
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Vadim Mikheev
Date:
Subject: Re: [HACKERS] (Debian Bug#41223) cascaded updates with refint insert bogus data
Next
From: Bruce Momjian
Date:
Subject: Re: [SQL] Re: [HACKERS] Counting bool flags in a complex query