Обсуждение: [GENERAL] Immutable functions and cache invalidation.

Поиск
Список
Период
Сортировка

[GENERAL] Immutable functions and cache invalidation.

От
Tim Uckun
Дата:
Say I have a function like this.

CREATE OR REPLACE FUNCTION some_constant(
)
    RETURNS text
    LANGUAGE 'plpgsql'
    COST 100
    IMMUTABLE 
    ROWS 0
AS $BODY$
begin
return 'some_string';
end;
$BODY$;

Then I have another function that calls it but is also immutable

CREATE OR REPLACE FUNCTION some_proc(
)
    RETURNS text
    LANGUAGE 'plpgsql'
    COST 100
    IMMUTABLE 
    ROWS 0
AS $BODY$
declare 
  x textl;
begin

x := some_constant();
....
end;
$BODY$;

will postgres know to invalidate the cache on some_proc() if I change the returned value in some_constant()?

Thanks.