From: | "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> |
---|---|
To: | "pgsql-hackers" <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | selectivity calculation for or_clause is wrong ? |
Date: | 1999-07-20 03:40:18 |
Message-ID: | 000401bed261$965d2520$2801007e@cadzone.tpf.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)tpf(dot)co(dot)jp
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-07-20 04:21:43 | Another reason to redesign querytree representation |
Previous Message | Bruce Momjian | 1999-07-20 03:33:06 | Re: [SQL] Re: [HACKERS] Counting bool flags in a complex query |