You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DDL:
set term ^;
recreate function fx(a_n int) returns varchar(31) deterministic as
begin
return (select rt.rdb$type_name from rdb$types rt order by rt.rdb$type rows (:a_n) to (:a_n));
end
^set term ;^
Test-1: select fx(10) from rdb$formats rows 1
Trace-1:
select fx(10) from rdb$formats rows 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PLAN (RDB$FORMATS NATURAL)
1 records fetched
0 ms, 519 fetch(es)
Table Natural
unge
******************************************
****
RDB$FORMATS 1
RDB$TYPES 251
Test-2: select fx(10) from rdb$formats rows 5;
Trace-2:
Statement 30:
------------------------------------------
select fx(10) from rdb$formats rows 5
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PLAN (RDB$FORMATS NATURAL)
5 records fetched
1 ms, 2585 fetch(es)
Table Natural
unge
******************************************
****
RDB$FORMATS 5
RDB$TYPES 1255
So, stored function re-reads RDB$TYPES table for each row of source.
It will be good for performance if all input arguments will be mapped to output results of such functions.
The text was updated successfully, but these errors were encountered:
Submitted by: @pavel-zotov
Votes: 1
DDL:
set term ^;
recreate function fx(a_n int) returns varchar(31) deterministic as
begin
return (select rt.rdb$type_name from rdb$types rt order by rt.rdb$type rows (:a_n) to (:a_n));
end
^set term ;^
Test-1: select fx(10) from rdb$formats rows 1
Trace-1:
select fx(10) from rdb$formats rows 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PLAN (RDB$FORMATS NATURAL)
1 records fetched
0 ms, 519 fetch(es)
Table Natural
unge
******************************************
****
RDB$FORMATS 1
RDB$TYPES 251
Test-2: select fx(10) from rdb$formats rows 5;
Trace-2:
Statement 30:
------------------------------------------
select fx(10) from rdb$formats rows 5
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PLAN (RDB$FORMATS NATURAL)
5 records fetched
1 ms, 2585 fetch(es)
Table Natural
unge
******************************************
****
RDB$FORMATS 5
RDB$TYPES 1255
So, stored function re-reads RDB$TYPES table for each row of source.
It will be good for performance if all input arguments will be mapped to output results of such functions.
The text was updated successfully, but these errors were encountered: