From: | Paul Ramsey <pramsey(at)cleverelephant(dot)ca> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Simon Riggs <simon(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PATCH] postgres_fdw extension support |
Date: | 2015-07-21 14:55:17 |
Message-ID: | CACowWR1nqFZRkr81JNBHh3qaJgUXGVgvRGcdEhmUMT5fJqRa2g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 21, 2015 at 7:45 AM, Andres Freund <andres(at)anarazel(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2015-07-21 14:58:15 | Re: PL/pgSQL, RAISE and error context |
Previous Message | Bjorn Munch | 2015-07-21 14:45:21 | Re: Solaris testers wanted for strxfrm() behavior |