Re: [HACKERS] <> join selectivity estimate question
От | Dilip Kumar |
---|---|
Тема | Re: [HACKERS] <> join selectivity estimate question |
Дата | |
Msg-id | CAFiTN-uLYwPAeEnm3-jbJ4dunKuQtjE5n=Wf_8b+OJ-i1BjMbA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [HACKERS] <> join selectivity estimate question (Thomas Munro <thomas.munro@enterprisedb.com>) |
Ответы |
Re: [HACKERS] <> join selectivity estimate question
|
Список | pgsql-hackers |
On Fri, Mar 17, 2017 at 6:49 PM, Thomas Munro <thomas.munro@enterprisedb.com> wrote: > Right. If I temporarily hack neqjoinsel() thus: > > result = 1.0 - result; > + > + if (jointype == JOIN_SEMI) > + result = 1.0; > + > PG_RETURN_FLOAT8(result); > } I was looking into this problem. IMHO, the correct solution will be that for JOIN_SEMI, neqjoinsel should not estimate the equijoin selectivity using eqjoinsel_semi, instead, it should calculate the equijoin selectivity as inner join and it should get the selectivity of <> by (1-equijoin selectivity). Because for the inner_join we can claim that "selectivity of '=' + selectivity of '<>' = 1", but same is not true for the semi-join selectivity. For semi-join it is possible that selectivity of '=' and '<>' is both are 1. something like below ---------------------------- @@ -2659,7 +2659,13 @@ neqjoinsel(PG_FUNCTION_ARGS) SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) PG_GETARG_POINTER(4); Oid eqop; float8 result; + if (jointype = JOIN_SEMI) + { + sjinfo->jointype = JOIN_INNER; + } /* * We want 1 - eqjoinsel() where the equality operator is the one * associated with this!= operator, that is, its negator. We may need something similar for anti-join as well. -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: