mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 23:23:02 +01:00
39b019574a
* Feature #7675 - EXPLAIN statement and RDB$SQL package. * Change ObjectsArray::back() to match STL semantics and add front() method. * Fix indentation problem. * Add OBJECT_TYPE column. * Add CARDINALITY column. * Add conversion from bid to ISC_QUAD. * Replace fb_assert by static_assert. * Change ACCESS_PATH output parameter to blob. * Improve docs.
1.5 KiB
1.5 KiB
RDB$SQL package (FB 6.0)
RDB$SQL
is a package with utility routines to work with dynamic SQL.
Procedure EXPLAIN
RDB$SQL.EXPLAIN
returns tabular information of a query's plan, without execute the query.
Since SQL
text generally is multi-line string and have quotes, you may use <alternate string literal>
(strings prefixed by Q
) as a way to make escape easy.
Input parameters:
SQL
typeBLOB SUB_TYPE TEXT CHARACTER SET UTF8 NOT NULL
- query statement
Output parameters:
PLAN_LINE
typeINTEGER NOT NULL
- plan's line orderRECORD_SOURCE_ID
typeBIGINT NOT NULL
- record source idPARENT_RECORD_SOURCE_ID
typeBIGINT
- parent record source idLEVEL
typeINTEGER NOT NULL
- indentation level (may have gaps in relation to parent's level)PACKAGE_NAME
typeRDB$PACKAGE_NAME
- package name of a stored procedureOBJECT_NAME
typeRDB$RELATION_NAME
- object (table, procedure) nameALIAS
typeRDB$RELATION_NAME
- alias nameRECORD_LENGTH
typeINTEGER
- record length for the record sourceKEY_LENGTH
typeINTEGER
- key length for the record sourceACCESS_PATH
typeVARCHAR(255) CHARACTER SET UTF8 NOT NULL
- friendly plan description
select *
from rdb$sql.explain('select * from employees where id = ?');
select *
from rdb$sql.explain(q'{
select *
from (
select name from employees
union all
select name from customers
)
where name = ?
}');
Authors
- Adriano dos Santos Fernandes