select ( select first 1 r.rdb$relation_name
from rdb$relations r
where r.rdb$relation_id = d.rdb$relation_id - 1 )
from (
select * from rdb$database
union all
select * from rdb$database
) d
PLAN (R NATURAL)
-- R is scanned naturally
PLAN (D RDB$DATABASE NATURAL)
PLAN (D RDB$DATABASE NATURAL)
But (without union):
select ( select first 1 r.rdb$relation_name
from rdb$relations r
where r.rdb$relation_id = d.rdb$relation_id - 1 )
from (
select * from rdb$database
) d
PLAN (R INDEX (RDB$INDEX_1))
-- R is read through the index
PLAN (D RDB$DATABASE NATURAL)
Test case 2 (with union):
select 1
from (
select * from rdb$relations
union all
select * from rdb$relations
) r
where exists ( select * from rdb$relation_fields f where f.rdb$relation_name = r.rdb$relation_name )
PLAN (F NATURAL)
PLAN (R RDB$RELATIONS NATURAL)
PLAN (R RDB$RELATIONS NATURAL)
But (without union):
select 1
from ( select * from rdb$relations ) r
where exists ( select * from rdb$relation_fields f where f.rdb$relation_name = r.rdb$relation_name )
PLAN (F INDEX (RDB$INDEX_4))
PLAN (R RDB$RELATIONS NATURAL)
Description
Test case 1 (with union):
select ( select first 1 r.rdb$relation_name
from rdb$relations r
where r.rdb$relation_id = d.rdb$relation_id - 1 )
from (
select * from rdb$database
union all
select * from rdb$database
) d
PLAN (R NATURAL)
-- R is scanned naturally
PLAN (D RDB$DATABASE NATURAL)
PLAN (D RDB$DATABASE NATURAL)
But (without union):
select ( select first 1 r.rdb$relation_name
from rdb$relations r
where r.rdb$relation_id = d.rdb$relation_id - 1 )
from (
select * from rdb$database
) d
PLAN (R INDEX (RDB$INDEX_1))
-- R is read through the index
PLAN (D RDB$DATABASE NATURAL)
Test case 2 (with union):
select 1
from (
select * from rdb$relations
union all
select * from rdb$relations
) r
where exists ( select * from rdb$relation_fields f where f.rdb$relation_name = r.rdb$relation_name )
PLAN (F NATURAL)
PLAN (R RDB$RELATIONS NATURAL)
PLAN (R RDB$RELATIONS NATURAL)
But (without union):
select 1
from ( select * from rdb$relations ) r
where exists ( select * from rdb$relation_fields f where f.rdb$relation_name = r.rdb$relation_name )
PLAN (F INDEX (RDB$INDEX_4))
PLAN (R RDB$RELATIONS NATURAL)
The cvs commits can not be displayed for repository Firebird at the moment since the log has not yet been parsed. The log will be parsed the next time the VcsService runs. If you have administrators privileges you can hasten the next time the service will run in the service section of the Administration pages.