Re: lcr v5 - primary/candidate key in relcache

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: lcr v5 - primary/candidate key in relcache
Дата
Msg-id 20130905170710.GC349020@alap2.anarazel.de
обсуждение исходный текст
Ответ на Re: logical changeset generation v5  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: lcr v5 - primary/candidate key in relcache  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
Hi Kevin,

On 2013-09-03 11:40:57 -0400, Robert Haas wrote:
> On Fri, Aug 30, 2013 at 11:19 AM, Andres Freund <andres@2ndquadrant.com> wrote:
> > 0007 wal_decoding: Add information about a tables primary key to struct RelationData
> > * Could be used in the matview refresh code

> I think you and Kevin should discuss whether this is actually the
> right way to do this.  ISTM that if logical replication and
> materialized views end up selecting different approaches to this
> problem, everybody loses.

The patch we're discussion here adds a new struct RelationData field
called 'rd_primary' (should possibly be renamed) which contains
information about the "best" candidate key available for a table.

>From the header comments:
    /*
     * The 'best' primary or candidate key that has been found, only set
     * correctly if RelationGetIndexList has been called/rd_indexvalid > 0.
     *
     * Indexes are chosen in the following order:
     * * Primary Key
     * * oid index
     * * the first (OID order) unique, immediate, non-partial and
     *   non-expression index over one or more NOT NULL'ed columns
     */
    Oid rd_primary;

I thought we could use that in matview.c:refresh_by_match_merge() to
select a more efficient diff if rd_primary has a valid index. In that
case you only'd need to compare that index's fields which should result
in an more efficient plan.

Maybe it's also useful in other cases for you?

If it's relevant at all, would you like to have a different priority
list than the one above?

Regards,

Andres Freund

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: improve Chinese locale performance
Следующее
От: arthernan
Дата:
Сообщение: Re: Where can I find the code for extern OidFunctionCall7?