Search...
ctrl/
Light
Dark
System
Sign in

System Functions and Types​

sys::get_version()

Return the server version as a tuple.

sys::get_version_as_str()

Return the server version as a string.

sys::get_current_database()

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.

function

sys::get_version()
sys::get_version() -> tuple<major: int64, minor: int64, stage: sys::VersionStage, stage_no: int64, local: array<str>>

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.

Copy
db> 
select sys::get_version();
{(major := 1, minor := 0, stage := <sys::VersionStage>'alpha',
  stage_no := 1, local := [])}

function

sys::get_version_as_str()
sys::get_version_as_str() -> str

Return the server version as a string.

Copy
db> 
select sys::get_version_as_str();
{'1.0-alpha.1'}

function

sys::get_transaction_isolation()
sys::get_transaction_isolation() -> sys::TransactionIsolation

Return the isolation level of the current transaction.

Possible return values are given by sys::TransactionIsolation.

Copy
db> 
select sys::get_transaction_isolation();
{sys::TransactionIsolation.Serializable}

function

sys::get_current_database()
sys::get_current_database() -> str

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).

Copy
db> 
select sys::get_current_database();
{'my_database'}

functionAdded in v5.0

sys::get_current_branch()
Added in v5.0
sys::get_current_branch() -> str

Return the name of the current database branch as a string.

Copy
db> 
select sys::get_current_branch();
{'my_branch'}

type

TransactionIsolation

Enum indicating the possible transaction isolation modes.

This enum only accepts a value of Serializable.

typeNew

sys::Branch
New
Branch

A read-only type representing all database branches.

name -> str

The name of the branch.

last_migration -> str

The name of the last migration applied to the branch.

typeNew

sys::QueryStats
New
QueryStats

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 and max_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 the minmax_only parameter set to true 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 the minmax_only parameter set to true 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 the minmax_only parameter set to true.

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 the minmax_only parameter set to true.

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.

typeNew

QueryType
New

Enum indicating the possible query types.

Possible values are:

  • EdgeQL

  • SQL

typeNew

OutputFormat
New

Enum indicating the possible output formats in a binary protocol.

Possible values are:

  • BINARY

  • JSON

  • JSON_ELEMENTS

  • NONE

functionNew

sys::reset_query_stats()
New
sys::reset_query_stats( named only branch_name: OPTIONAL str = {}, named only id: OPTIONAL uuid = {}, named only minmax_only: OPTIONAL bool = false, ) -> OPTIONAL datetime

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.

Copy
db> 
select sys::reset_query_stats();
{'2021-01-01T00:00:00Z'}
Copy
db> 
select sys::reset_query_stats(branch_name := 'my_branch');
{'2021-01-01T00:00:00Z'}
Copy
db> 
select sys::reset_query_stats(id := <uuid>'00000000-0000-0000-0000-000000000000');
{'2021-01-01T00:00:00Z'}
Copy
db> 
select sys::reset_query_stats(minmax_only := true);
{'2021-01-01T00:00:00Z'}
Copy
db> 
select sys::reset_query_stats(branch_name := 'no_such_branch');
{}