Home > Enterprise >  Query on SNOWFLAKE.ACCOUNT_USAGE schema taking long time to run
Query on SNOWFLAKE.ACCOUNT_USAGE schema taking long time to run

Time:05-07

I am trying to run a simple query against any of the tables contained in SNOWFLAKE.ACCOUNT_USAGE schema but for some reason it is taking up a long time to run even if I try to limit it to show only the first row, like the following example:

SELECT * FROM "SNOWFLAKE"."ACCOUNT_USAGE"."ACCESS_HISTORY" limit 1;

Is that a normal behavior? If not, can someone help me to figure out why this is happening?

CodePudding user response:

Its always a good practice to add a WHERE condition so the optimizer can make use of query pruning. If you know your objects were accessed within the past say 24 hours, can you add a date filter and see if that helps?

SELECT * FROM "SNOWFLAKE"."ACCOUNT_USAGE"."ACCESS_HISTORY" 
WHERE QUERY_START_TIME > CURRENT_DATE() - 1 
limit 1;

More info on mirco-partitions and query pruning: https://docs.snowflake.com/en/user-guide/tables-clustering-micropartitions.html#query-pruning

  • Related