Re: Function result cacheing - any comments?

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: Function result cacheing - any comments?
Дата
Msg-id 3D60823F.5000900@joeconway.com
обсуждение исходный текст
Ответ на Re: Function result cacheing - any comments?  (Philip Warner <pjw@rhyme.com.au>)
Ответы Re: Function result cacheing - any comments?
Re: Function result cacheing - any comments?
Список pgsql-hackers
Philip Warner wrote:
> So the obvious question is - in the opinion of people who know the code, 
> can a function-result-cache be implemented with a lifetime of a single 
> statement, without butchering the function manager?
> 

I don't know if I fully understand what you're proposing, but if I 
understand it correctly, I think the table function feature in current 
sources does just what you want already. If you can write your function 
as a table function, the results are put in a tuplestore for the 
duration of the statement, and rescanned when needed.

Your example ends up looking like this:

create table departments(id integer, name text, manager_id integer);
insert into departments values(1, 'manufacturing', 1);
insert into departments values(2, 'accounting', 2);

create table people(id integer, department_id, name text);
insert into people values(1, 1, 'mfg boss');
insert into people values(2, 2, 'acct boss');
insert into people values(3, 1, 'mfg emp');
insert into people values(4, 2, 'acct emp');

create type manager_names as (dept_id int, name text);

create function get_manager_names() returns setof manager_names as    'select d.id, p.name from departments d, people p
   where p.id = d.manager_id' language sql;
 

select p.name, m.name as boss from people p, get_manager_names() m where 
p.department_id = m.dept_id;   name    |   boss
-----------+----------- mfg boss  | mfg boss mfg emp   | mfg boss acct boss | acct boss acct emp  | acct boss
(4 rows)

Is this anything close what you had in mind?

Joe



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

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Removing Libraries (Was: Re: Open 7.3 issues)
Следующее
От: Philip Warner
Дата:
Сообщение: Re: Function result cacheing - any comments?