Re: Logical Replication WIP

From: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, Steve Singer <steve(at)ssinger(dot)info>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers-owner(at)postgresql(dot)org
Subject: Re: Logical Replication WIP
Date: 2016-12-13 05:55:31
Message-ID: 71989387-bf1b-8a48-4d30-07bf14ae83a6@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13/12/16 03:26, Petr Jelinek wrote:
> On 13/12/16 02:41, Andres Freund wrote:
>> On 2016-12-10 08:48:55 +0100, Petr Jelinek wrote:
>>
>>> +static List *
>>> +OpenTableList(List *tables)
>>> +{
>>> + List *relids = NIL;
>>> + List *rels = NIL;
>>> + ListCell *lc;
>>> +
>>> + /*
>>> + * Open, share-lock, and check all the explicitly-specified relations
>>> + */
>>> + foreach(lc, tables)
>>> + {
>>> + RangeVar *rv = lfirst(lc);
>>> + Relation rel;
>>> + bool recurse = interpretInhOption(rv->inhOpt);
>>> + Oid myrelid;
>>> +
>>> + rel = heap_openrv(rv, ShareUpdateExclusiveLock);
>>> + myrelid = RelationGetRelid(rel);
>>> + /* filter out duplicates when user specifies "foo, foo" */
>>> + if (list_member_oid(relids, myrelid))
>>> + {
>>> + heap_close(rel, ShareUpdateExclusiveLock);
>>> + continue;
>>> + }
>>
>> This is a quadratic algorithm - that could bite us... Not sure if we
>> need to care. If we want to fix it, one approach owuld be to use
>> RangeVarGetRelid() instead, and then do a qsort/deduplicate before
>> actually opening the relations.
>>
>
> I guess it could get really slow only with big inheritance tree, I'll
> look into how much work is the other way of doing things (this is not
> exactly hot code path).
>

Actually looking at it, it only processes user input so I don't think
it's very problematic in terms of performance. You'd have to pass many
thousands of tables in single DDL to notice.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2016-12-13 06:11:03 Re: Radix tree for character conversion
Previous Message Michael Paquier 2016-12-13 05:44:07 Re: Password identifiers, protocol aging and SCRAM protocol