create trusted language 'plpgsql'
handler plpgsql_call_handler lancompiler 'PL/pgSQL';

create table small ( only_item int4 );

create or replace function slow_function(int4, int4) returns int4 as $$
declare
    x int4;
    y int4;
    ret int4 := 2;
begin
    for x in 1..$1 loop
        for y in 1..$2 loop
            ret := ret+(x/y);
        end loop;
    end loop;
    return ret;
end;
$$ language plpgsql;

create or replace view small_v as
  
    select i.only_item as item1,
    slow_function(i.only_item,i.only_item) as item2
    from small i
  ;


insert into small values (1); 
insert into small values (3); 
insert into small values (10); 
insert into small values (25); 
insert into small values (100); 
insert into small values (250); 
insert into small values (1000); 
insert into small values (2500); 

select item1 from small_v;
select item2 from small_v;


drop view small_v;
drop function slow_function(int4,int4);
drop table small;
drop language 'plpgsql';
