Re: [PATCH] postgres_fdw extension support - Mailing list pgsql-hackers

From Paul Ramsey
Subject Re: [PATCH] postgres_fdw extension support
Date
Msg-id CACowWR1nqFZRkr81JNBHh3qaJgUXGVgvRGcdEhmUMT5fJqRa2g@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] postgres_fdw extension support  (Andres Freund <andres@anarazel.de>)
Responses Re: [PATCH] postgres_fdw extension support  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Tue, Jul 21, 2015 at 7:45 AM, Andres Freund <andres@anarazel.de> wrote:

>> +
>> +     /* We need this relation to scan */
>> +     depRel = heap_open(DependRelationId, RowExclusiveLock);
>> +
>> +     /* Scan the system dependency table for a all entries this operator */
>> +     /* depends on, then iterate through and see if one of them */
>> +     /* is a registered extension */
>> +     ScanKeyInit(&key[0],
>> +                             Anum_pg_depend_objid,
>> +                             BTEqualStrategyNumber, F_OIDEQ,
>> +                             ObjectIdGetDatum(procnumber));
>> +
>> +     scan = systable_beginscan(depRel, DependDependerIndexId, true,
>> +                                                       GetCatalogSnapshot(depRel->rd_id), nkeys, key);
>> +
>> +     while (HeapTupleIsValid(tup = systable_getnext(scan)))
>> +     {
>> +             Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
>> +
>> +             if ( foundDep->deptype == DEPENDENCY_EXTENSION )
>> +             {
>> +                     List *extlist = fpinfo->extensions;
>> +                     ListCell *ext;
>> +
>> +                     foreach(ext, extlist)
>> +                     {
>> +                             Oid extension_oid = (Oid) lfirst(ext);
>> +                             if ( foundDep->refobjid == extension_oid )
>> +                             {
>> +                                     nresults++;
>> +                             }
>> +                     }
>> +             }
>> +             if ( nresults > 0 ) break;
>> +     }
>> +
>> +     systable_endscan(scan);
>> +     relation_close(depRel, RowExclusiveLock);
>> +
>> +     return nresults > 0;
>> +}
>
> Phew. That's mighty expensive to do at frequency.
>
> I guess it'll be more practical to expand this list once and then do a
> binary search on the result for the individual functions

So, right after reading the options in postgresGetForeignRelSize,
expand the extension list into a list of all ops/functions, in a
sorted list, and let that carry through to the deparsing instead? That
would happen once per query, right? But the deparsing also happens
once per query too, yes? Is the difference going to be that big? (I
speak not knowing the overhead of things like systable_beginscan, etc)

Thanks!

P



pgsql-hackers by date:

Previous
From: Bjorn Munch
Date:
Subject: Re: Solaris testers wanted for strxfrm() behavior
Next
From: Merlin Moncure
Date:
Subject: Re: PL/pgSQL, RAISE and error context