RE: Function search_path

Поиск
Список
Период
Сортировка
От Heinemann, Manfred (IMS)
Тема RE: Function search_path
Дата
Msg-id da2ee034500f4639b7c03b58f18f147a@THALASSA.omni.imsweb.com
обсуждение исходный текст
Ответ на Re: Function search_path  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Function search_path  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
>> I have played around with the postgres memory settings and setting search_path on a function causes a lot more
memoryto be used than if no search_path was set. 
>
>That's a pretty broad claim with a pretty small amount of evidence offered.
>
>I can certainly believe that attaching a SET clause (whether for search_path or any other GUC variable) would have an
efficiencyimpact; one non-obvious example is that it prevents inlining if the function is a SQL function.  But I don't
immediatelysee a reason for major memory consumption from that.  I suspect what you're seeing is specific to a
particularuse-case.  If you were to provide a concrete example, we could look into what's happening. 
>
>regards, tom lane

Here is an example where I can show significant extra memory consumption when setting search_path on a function:

CREATE TABLE test_search_path(date_last_modified timestamp, last_name varchar);

--populate 1,000,000 rows with random values from 1,000 surnames for 'SURNAME'
INSERT INTO test_search_path(date_last_modified, last_name) VALUES(clock_timestamp(), 'SURNAME');

CREATE OR REPLACE FUNCTION clean_name_upper(original_name varchar)
  RETURNS varchar
  LANGUAGE plpgsql
AS $$
BEGIN
  RETURN trim(upper(original_name));
END;
$$ IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION split_name_on_hyphen(original_name character varying)
  RETURNS text[]
  LANGUAGE plpgsql
AS $$
BEGIN
    RETURN string_to_array(clean_name_upper(original_name), '-');
END;
$$ IMMUTABLE STRICT SET search_path = '$user';

CREATE INDEX idx_test_search_path_clean_name_upper_last_name ON test_search_path (clean_name_upper(last_name));
CREATE INDEX idx_test_search_path_split_name_on_hyphen_last_name ON test_search_path USING
gin(split_name_on_hyphen(last_name));

UPDATE test_search_path SET date_last_modified = (date_last_modified - interval '7 days');

This only seems to be an issue when indices exist for both functions and when the inner called function does not have
search_pathset. 

Thanks,
Manfred

________________________________

Information in this e-mail may be confidential. It is intended only for the addressee(s) identified above. If you are
notthe addressee(s), or an employee or agent of the addressee(s), please note that any dissemination, distribution, or
copyingof this communication is strictly prohibited. If you have received this e-mail in error, please notify the
senderof the error. 


В списке pgsql-admin по дате отправления:

Предыдущее
От: Shreeyansh Dba
Дата:
Сообщение: Re: Number of updated rows in postgres
Следующее
От: Mario Mahovlić
Дата:
Сообщение: Re: Very long standby database startup after doing pg_basebackup