Pessoal, tenho algumas funções declaradas como STABLE, que estão sendo
executadas várias vezes no statement e segundo a documentação, isso não
deveria acontecer...

"A STABLE function cannot modify the database and is guaranteed to return
the same results given the same arguments for all rows within a single
statement. This category allows the optimizer to optimize multiple calls of
the function to a single call. In particular, it is safe to use an
expression containing such a function in an index scan condition. (Since an
index scan will evaluate the comparison value only once, not once at each
row, it is not valid to use a VOLATILE function in an index scan
condition.)"

EX:

SELECT func, func + 1 FROM
                (
                 SELECT fnc_stable(34) as func
                ) AS foo

OU

SELECT fnc_stable(34) as foo,
              fnc_stable(34) as foobar

 As funções nestes exemplos serão executadas duas vezes, quando "deveriam"
ser executadas apenas uma vez e o resultado ser aproveitado nas demais
chamadas da função.
Será que estou me confundindo em algum conceito? Isso está prejudicando
demais a performance das consultas.

abraços...

-- 
Pedro Ivo Bispo de França
X-Brain - Desenvolvimento de Sistemas Ltda
Contato: +55 43 3304-2204 | +55 43 9608-3678
Avenida Tiradentes, 501 Sala 702 Torre 1 - Jd. Shangrilá
Londrina - Paraná - 86070-545
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a