Performance/Security question on caching function OIDs for a connection

From: Weslee Bilodeau <weslee(dot)bilodeau(at)hypermediasystems(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Performance/Security question on caching function OIDs for a connection
Date: 2006-10-18 20:46:04
Message-ID: 4536928C.6060205@hypermediasystems.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm working on my custom encryption types (as outlined in another
thread) and was curious of one potential performance hit.

On the input and output functions for the new type, I lookup the
encrypt/decrypt functions using -

FuncnameGetCandidates( list_make1( makeString( "decrypt" ) )

Running through the list and getting the functions OID, then calling
with OidFunctionCall3().

I'm concerned about the performance impact if say, importing thousands
of rows in a COPY, doing the lookup for every row. To get around this I
was thinking of doing the lookup once then caching the OIDs for the
functions (a per-connection cache, not globally).

I know the function can be dropped, I'm trapping the error so I'm not as
concerned, but is it possible for someone to replace the same OID with
another function?

My thoughts were if the call failed, perform another lookup for the new
OID, if it can't be found error out. But if the OID just points to a new
function it may not generate an error and just return something unexpected.

I'm not sure if its safe, or if I shouldn't even bother trying to cache
for performance?

I know it makes little difference when inserting one row as encryption
takes the bulk of the time, but when you scale to thousands+ inserts at
once?

Weslee

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2006-10-18 20:46:08 Re: [HACKERS] query log corrupted-looking entries
Previous Message Magnus Hagander 2006-10-18 20:41:19 Re: Mirror problems for download