page86
68
GET_QUERY_OPERATOR_STATS
GET_QUERY_OPERATOR_STATS
returns query operator information for completed queries.
You will use this new table function to later programmatically identify rogue queries.
GET_QUERY_OPERATOR_STATS
is limited to queries executed in the past 14 days.
For immediate results, you might prefer to use
last_query_id()
to identify
information from the most recently run SQL statement. Note that
GET_QUERY_OPERATOR_
STATS
may return
OPERATOR_TYPE
of
QUERY RESULT REUSE
, which indicates the source
query profile is inaccessible. In this example the query optimizer determined to use the
result cache.
The following is the general form of this query:
SELECT <attributes>
FROM TABLE ( get_query_operator_stats(<your value here>))
WHERE <predicates>
ORDER BY <ordering>;
GET_QUERY_OPERATOR_STATS
accepts a single value, which must be one of the
following:
•
The value returned by
last_query_id()
•
A session variable containing a valid
query_id
•
A string literal set to valid
query_id
•
The
query_id
values used throughout this book will vary when
executed against your Snowflake account.
You will return to
GET_QUERY_OPERATOR_STATS
throughout the rest of this book. You
can find further information at
https://docs.snowflake.com/en/sql-reference/
functions/get_query_operator_stats
.
ChapTer 3
The Query profiler