Re: [PATCH] Keeps tracking the uniqueness with UniqueKey

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [PATCH] Keeps tracking the uniqueness with UniqueKey
Дата
Msg-id 2320222.1607200823@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [PATCH] Keeps tracking the uniqueness with UniqueKey  (Heikki Linnakangas <hlinnaka@iki.fi>)
Ответы Re: [PATCH] Keeps tracking the uniqueness with UniqueKey  (Andy Fan <zhihui.fan1213@gmail.com>)
Список pgsql-hackers
Heikki Linnakangas <hlinnaka@iki.fi> writes:
>> I can understand why we need EquivalenceClass for UniqueKey, but I can't
>> understand why we need opfamily here.

> Thinking a bit harder, I guess we don't. Because EquivalenceClass 
> includes the operator family already, in the ec_opfamilies field.

No.  EquivalenceClasses only care about equality, which is why they
might potentially mention several opfamilies that share an equality
operator.  If you care about sort order, you *cannot* rely on an
EquivalenceClass to depict that.  Now, abstract uniqueness also only
cares about equality, but if you are going to implement it via sort-
and-unique then you need to settle on a sort order.

I agree we are overspecifying DISTINCT by settling on a sort operator at
parse time, rather than considering all the possibilities at plan time.
But given that opfamilies sharing equality are mostly a hypothetical
use-case, I'm not in a big hurry to fix it.  Before we had ASC/DESC
indexes, there was a real use-case for making a "reverse sort" opclass,
with the same equality as the type's regular opclass but the opposite sort
order.  But that's ancient history now, and I've seen few other plausible
use-cases.

I have not been following this thread closely enough to understand
why we need a new "UniqueKeys" data structure at all.  But if the
motivation is only to remove this overspecification, I humbly suggest
that it ain't worth the trouble.

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: Index Skip Scan (new UniqueKeys)
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Change definitions of bitmap flags to bit-shifting style