Re: PostgreSQL executing my function too many times during query - Mailing list pgsql-general

From D. Dante Lorenso
Subject Re: PostgreSQL executing my function too many times during query
Date
Msg-id 482CD962.7080405@lorenso.com
Whole thread Raw
In response to Re: PostgreSQL executing my function too many times during query  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PostgreSQL executing my function too many times during query
List pgsql-general
Tom Lane wrote:
> "D. Dante Lorenso" <dante@lorenso.com> writes:
>> This format causes the function to execute too many times:
>
>>    SELECT COUNT(*) AS result
>>    FROM credit_card
>>    WHERE card_number_enc = cc_encrypt('4111-1111-1111-1111', 'pwd')
>>    AND card_number_enc != cc_encrypt('4111111111111111', 'pwd');
>
> If the function is marked immutable that query should certainly evaluate
> it only twice.
>
> I notice that the EXPLAINs show it as credit_card_encrypt() not
> cc_encrypt() --- maybe you got confused about which function you
> were adjusting the properties of?

Sorry I was trying to shorten the function name to help with email
wrapping.  It was credit_card_encrypt.  I didn't do reps in all places.

So, that not being the problem, any ideas?  Is it an 8.2.4 thing?

-- Dante

pgsql-general by date:

Previous
From: "Vance Maverick"
Date:
Subject: triggers: dynamic references to fields in NEW and OLD?
Next
From: Adrian Klaver
Date:
Subject: Re: problem with serial data type and access