Re: [PATCH] Keeps tracking the uniqueness with UniqueKey

Поиск
Список
Период
Сортировка
От Andy Fan
Тема Re: [PATCH] Keeps tracking the uniqueness with UniqueKey
Дата
Msg-id CAKU4AWpOM3_J-B=wQtCeU1TGr89MhpJBBkv2he1tAeQz6i4XNw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Keeps tracking the uniqueness with UniqueKey  (Andy Fan <zhihui.fan1213@gmail.com>)
Список pgsql-hackers
The attached is the v8-patches.  The main improvements are based on Ashutosh's
review (reduce the SRF impact and partition level UniqueKey). I also update the
README.uniquekey based on the discussion. So anyone who don't want to go
through the long email can read the README.uniquekey first.

===
Just copy some content from the README for easy discussion. 

As for inherit table, we maintain the UnqiueKey on childrel as usual. But for
partitioned table we need to maintain 2 different kinds of UnqiueKey. 
1). UniqueKey on the parent relation 2). UniqueKey on child relation for 
partition wise query.

Example:
CREATE TABLE p (a int not null, b int not null) partition by list (a);
CREATE TABLE p0 partition of p for values in (1);
CREATE TABLE p1 partition of p for values in (2);

create unique index p0_b on p0(b);
create unique index p1_b on p1(b);

Now b is unique on partition level only, so the distinct can't be removed on
the following cases. SELECT DISTINCT b FROM p; However for query 
SELECT DISTINCT b FROM p WHERE a = 1; where only one
partition is chosen, the UniqueKey on child relation is same as the UniqueKey
on parent relation. The distinct can be removed.

Another usage of UniqueKey on partition level is it be helpful for
partition-wise join.

As for the UniqueKey on parent table level, it comes with 2 different ways.

1). the UniqueKey is also derived in Unique index, but the index must be same
in all the related children relations and the unique index must contains
Partition Key in it. Example:

CREATE UNIQUE INDEX p_ab ON p(a, b);  -- where a is the partition key.

-- Query
SELECT a, b FROM p;     -- the (a, b) is a UniqueKey of p.

 2). If the parent relation has only one childrel, the UniqueKey on childrel is
 the UniqueKey on parent as well.

The patch structure is not changed,  you can see [1] for reference. The patches is 
based on latest commit ac3a4866c0. 


Best Regards
Andy Fan
Вложения

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

Предыдущее
От: Sumanta Mukherjee
Дата:
Сообщение: Re: refactoring basebackup.c
Следующее
От: Ashutosh Bapat
Дата:
Сообщение: Re: [PATCH] Keeps tracking the uniqueness with UniqueKey