Re: PostgreSQL executing my function too many times during query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "D(dot) Dante Lorenso" <dante(at)lorenso(dot)com>
Cc: Postgres-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL executing my function too many times during query
Date: 2008-05-15 23:05:23
Message-ID: 18643.1210892723@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"D. Dante Lorenso" <dante(at)lorenso(dot)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?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message D. Dante Lorenso 2008-05-16 00:46:26 Re: PostgreSQL executing my function too many times during query
Previous Message D. Dante Lorenso 2008-05-15 22:51:59 PostgreSQL executing my function too many times during query