Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deterministic stored functions in FB 3: provide ability to map input arguments to output values [CORE4361] #4683

Open
firebird-automations opened this issue Mar 9, 2014 · 1 comment

Comments

@firebird-automations
Copy link
Collaborator

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.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Currently DETERMINISTIC is useful only for no-parameters functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant