Re: lcr v5 - primary/candidate key in relcache - Mailing list pgsql-hackers

From Andres Freund
Subject Re: lcr v5 - primary/candidate key in relcache
Date
Msg-id 20130905170710.GC349020@alap2.anarazel.de
Whole thread Raw
In response to Re: logical changeset generation v5  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: lcr v5 - primary/candidate key in relcache
List 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

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: improve Chinese locale performance
Next
From: arthernan
Date:
Subject: Re: Where can I find the code for extern OidFunctionCall7?