System Functions and Types​
Return the server version as a tuple. | |
Return the server version as a string. | |
Return the name of the current database as a string. | |
sys::get_current_branch() (added in 5.0) |
Return the name of the current database branch as a string. |
sys::Branch (added in 6.0) |
A read-only type representing all database branches. |
sys::QueryStats (added in 6.0) |
A read-only type representing query performance statistics. |
sys::reset_query_stats() (added in 6.0) |
Discard selected query statistics gathered so far. |
Return the server version as a tuple.
The major
and minor
elements contain the major and the minor
components of the version; stage
is an enumeration value containing
one of 'dev'
, 'alpha'
, 'beta'
, 'rc'
or 'final'
;
stage_no
is the stage sequence number (e.g. 2
in an alpha 2
release); and local
contains an arbitrary array of local version
identifiers.
db>
select sys::get_version();
{(major := 1, minor := 0, stage := <sys::VersionStage>'alpha', stage_no := 1, local := [])}
Return the isolation level of the current transaction.
Possible return values are given by
sys::TransactionIsolation
.
db>
select sys::get_transaction_isolation();
{sys::TransactionIsolation.Serializable}
Return the name of the current database as a string.
This function is deprecated in Gel.
Use sys::get_current_branch()
(added in 5.0) instead
(it works in the same way).
db>
select sys::get_current_database();
{'my_database'}
Enum
indicating the possible transaction
isolation modes.
This enum only accepts a value of Serializable
.
A read-only type representing query performance statistics.
- branch -> sys::Branch
-
The
branch
(added in 6.0) this statistics entry was collected in. - query -> str
-
Text string of a representative query.
- query_type -> sys::QueryType
-
The
type
(added in 6.0) of the query. - tag -> str
-
Query tag, commonly specifies the origin of the query, e.g 'gel/cli' for queries originating from the CLI. Clients can specify a tag for easier query identification.
- stats_since -> datetime
-
Time at which statistics gathering started for this query.
- minmax_stats_since -> datetime
-
Time at which min/max statistics gathering started for this query (fields
min_plan_time
,max_plan_time
,min_exec_time
andmax_exec_time
).
All queries have to be planned by the backend before execution. The planned statements are cached (managed by the Gel server) and reused if the same query is executed multiple times.
- plans -> int64
-
Number of times the query was planned in the backend.
- total_plan_time -> duration
-
Total time spent planning the query in the backend.
- min_plan_time -> duration
-
Minimum time spent planning the query in the backend. This field will be zero if the counter has been reset using the
sys::reset_query_stats()
(added in 6.0) function with theminmax_only
parameter set totrue
and never been planned since. - max_plan_time -> duration
-
Maximum time spent planning the query in the backend. This field will be zero if the counter has been reset using the
sys::reset_query_stats()
(added in 6.0) function with theminmax_only
parameter set totrue
and never been planned since. - mean_plan_time -> duration
-
Mean time spent planning the query in the backend.
- stddev_plan_time -> duration
-
Population standard deviation of time spent planning the query in the backend.
After planning, the query is usually executed in the backend, with the result being forwarded to the client.
- calls -> int64
-
Number of times the query was executed.
- total_exec_time -> duration
-
Total time spent executing the query in the backend.
- min_exec_time -> duration
-
Minimum time spent executing the query in the backend. This field will be zero until this query is executed first time after reset performed by the
sys::reset_query_stats()
(added in 6.0) function with theminmax_only
parameter set totrue
. - max_exec_time -> duration
-
Maximum time spent executing the query in the backend. This field will be zero until this query is executed first time after reset performed by the
sys::reset_query_stats()
(added in 6.0) function with theminmax_only
parameter set totrue
. - mean_exec_time -> duration
-
Mean time spent executing the query in the backend.
- stddev_exec_time -> duration
-
Population standard deviation of time spent executing the query in the backend.
- rows -> int64
-
Total number of rows retrieved or affected by the query.
The following properties are used to identify a unique statistics entry (together with the query text above):
- compilation_config -> std::json
-
The config used to compile the query.
- protocol_version -> tuple<major: int16, minor: int16>
-
The version of the binary protocol receiving the query.
- default_namespace -> str
-
The default module/schema used to compile the query.
- namespace_aliases -> json
-
The module aliases used to compile the query.
- output_format -> sys::OutputFormat
-
The
OutputFormat
(added in 6.0) indicated in the binary protocol receiving the query. - expect_one -> bool
-
Whether the query is expected to return exactly one row.
- implicit_limit -> int64
-
The implicit limit set for the query.
- inline_typeids -> bool
-
Whether type IDs are inlined in the query result.
- inline_typenames -> bool
-
Whether type names are inlined in the query result.
- inline_objectids -> bool
-
Whether object IDs are inlined in the query result.
Enum
indicating the possible output formats in a binary
protocol.
Possible values are:
-
BINARY
-
JSON
-
JSON_ELEMENTS
-
NONE
Discard selected query statistics gathered so far.
Discard query statistics gathered so far corresponding to the specified
branch_name
and id
. If either of the parameters is not specified,
the statistics that match with the other parameter will be reset. If no
parameter is specified, it will discard all statistics. When minmax_only
is true
, only the values of minimum and maximum planning and execution
time will be reset (i.e. min_plan_time
, max_plan_time
,
min_exec_time
and max_exec_time
fields). The default value for
minmax_only
parameter is false
. This function returns the time of a
reset. This time is saved to stats_reset
or minmax_stats_since
field
of sys::QueryStats
(added in 6.0) if the corresponding reset was actually
performed.
db>
select sys::reset_query_stats();
{'2021-01-01T00:00:00Z'}
db>
select sys::reset_query_stats(branch_name := 'my_branch');
{'2021-01-01T00:00:00Z'}
db>
select sys::reset_query_stats(id := <uuid>'00000000-0000-0000-0000-000000000000');
{'2021-01-01T00:00:00Z'}
db>
select sys::reset_query_stats(minmax_only := true);
{'2021-01-01T00:00:00Z'}
db>
select sys::reset_query_stats(branch_name := 'no_such_branch');
{}