danD
danD

Reputation: 716

Is there a way to get the information about cancelled query

In our snowflake, we have multiple users accessing the database. And sometimes when query takes long time people are cancelling the query from UI. I was wondering if there is a way to get information about who has cancelled the query. Like we have table QUERY_HISTORY to get information about the query.

Do we have a similar table to get information of query cancelled?

Upvotes: 0

Views: 611

Answers (2)

Mike Walton
Mike Walton

Reputation: 7339

The question is whether there is a table that stores cancelled queries like QUERY_HISTORY, I think. The answer is that even a cancelled query will be in QUERY_HISTORY.

Upvotes: 0

Chris
Chris

Reputation: 690

Only the user who executed the query can cancel it via the Abort button in the UI. Other ways to cancel a query would be to issue one of the following functions:

  • SYSTEM$CANCEL_QUERY
  • SYSTEM$CANCEL_ALL_QUERIES
  • SYSTEM$ABORT_SESSION
  • SYSTEM$ABORT_TRANSACTION
  • ALTER WAREHOUSE ... ABORT ALL QUERIES
  • ALTER USER ... ABORT ALL QUERIES

Any one of the above functions that are issued would be a query in the QUERY_HISTORY as well.

A cancelled query will have an error of 604, and I expect that the error code is different if the query has timed out (which by default is set to 2 days).

Upvotes: 1

Related Questions