Para de bagunça a lista, pelamor.....
A gente responde LÁ EMBAIXO ! olha só:

Em sex, 2 de jun de 2017 às 16:39, Alexsander Rosa <
[email protected]> escreveu:

> laboratorio:rnge2=# EXPLAIN (ANALYZE, TIMING, BUFFERS) SELECT num_cupom
> FROM cf_cupom WHERE nfce_chave_acesso_fk =
> '43170605563868000113657010000004061895261728';
>                                                         QUERY PLAN
>
>
> --------------------------------------------------------------------------------------------------------------------------
>  Index Scan using idx_cupom_chave on cf_cupom  (cost=0.55..8.57 rows=1
> width=4) (actual time=0.078..0.079 rows=1 loops=1)
>    Index Cond: (nfce_chave_acesso_fk =
> '43170605563868000113657010000004061895261728'::bpchar)
>    Buffers: shared hit=5
>  Total runtime: 0.106 ms
> (4 rows)
>
>
> 2017-06-02 11:28 GMT-03:00 Alexsander Rosa <[email protected]>:
>
>> laboratorio:rnge2=# EXPLAIN (ANALYZE, TIMING, BUFFERS) SELECT
>> sp_teste('43170605563868000113657010000004061895261728');
>>                                         QUERY PLAN
>>
>>
>> ------------------------------------------------------------------------------------------
>>  Result  (cost=0.00..0.26 rows=1 width=0) (actual time=1523.013..1523.013
>> rows=1 loops=1)
>>    Buffers: shared hit=18998 read=123619 dirtied=3
>>  Total runtime: 1523.043 ms
>> (3 rows)
>>
>>
>> Em 2 de junho de 2017 11:11, Alexsander Rosa <[email protected]>
>> escreveu:
>>
>>> laboratorio:rnge2=# SELECT
>>> sp_teste('43170605563868000113657010000004061895261728');
>>>  sp_teste
>>> ----------
>>>  OK
>>> (1 row)
>>>
>>> Time: 1507,688 ms
>>> laboratorio:rnge2=#
>>>
>>> ----------------
>>> -- Código "pelado"
>>> CREATE OR REPLACE FUNCTION rnx.sp_teste(chave text)
>>>  RETURNS text
>>>  LANGUAGE plpgsql
>>> AS $function$
>>> DECLARE
>>> BEGIN
>>>   PERFORM num_cupom FROM cf_cupom WHERE nfce_chave_acesso_fk = chave;
>>>   Return 'OK';
>>> END;
>>> $function$
>>> ;
>>>
>>
Declare sua função como STABLE e tenta novamente.

[]s
Flavio Gurgel
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a