- Categories:
REPLICATION_ GROUP_ LAG_ HISTORY¶
Returns the replication lag history for a secondary failover group over a time window. The results show how the replication lag for the group changed over time, returned as a step function that you can plot.
The lag at a point in time is the difference between that time and the primary snapshot timestamp of the most recent completed refresh. Between refreshes, the lag increases as time passes. When a refresh completes, the lag drops because a newer snapshot becomes available.
By default (when no date-range arguments are provided), the function returns data for the last 24 hours.
Syntax¶
Arguments¶
REPLICATION_GROUP_NAME => 'string'Name of the secondary failover group to report on. The value must be a non-NULL constant and enclosed in single quotes. This argument is required.
The following arguments are optional.
START_TIME => constant_expr,
END_TIME => constant_exprThe
TIMESTAMP_LTZtime window (inclusive) for which to return the lag history:- If neither
START_TIMEnorEND_TIMEis specified, the default is the last 24 hours. - If
START_TIMEis omitted, it defaults to 24 hours before the current timestamp. - If
END_TIMEis omitted, it defaults to the current timestamp.
Both arguments must be constant values.
- If neither
Output¶
The function returns the following columns:
| Column Name | Data Type | Description |
|---|---|---|
| TIMESTAMP | TIMESTAMP_LTZ | Point in time for the lag measurement. |
| LAG_SECONDS | NUMBER | Replication lag, in seconds, at that timestamp. This is the difference between TIMESTAMP and PRIMARY_SNAPSHOT_TIMESTAMP. |
| PRIMARY_SNAPSHOT_TIMESTAMP | TIMESTAMP_LTZ | Primary snapshot timestamp from the most recent completed refresh in effect at that timestamp. |
Usage notes¶
- When no
START_TIMEorEND_TIMEarguments are provided, the function returns data for the last 24 hours. To retrieve data beyond the last 24 hours, specify the time window explicitly. - The function returns two rows for each refresh interval so that the lag history renders as a
step (sawtooth) function: one row at the moment a refresh completes (the start of the step), and
one row just before the next refresh, or before the window’s end time for the final interval (the
end of the step). Rows are ordered by
TIMESTAMP, and then byLAG_SECONDS. - Only returns rows for a secondary replication or failover group in the current account.
- When calling an Information Schema table function, the session must have an INFORMATION_SCHEMA schema in use or the function name must be fully-qualified. For more details, see Snowflake Information Schema.
Examples¶
Retrieve the replication lag history for the last 24 hours (default) for secondary group myrg:
Retrieve the replication lag history for a specific time window for secondary group myrg: