diff --git a/ingestion/src/metadata/orm_profiler/metrics/system/system.py b/ingestion/src/metadata/orm_profiler/metrics/system/system.py index e665cfa6ce0..c7c2c0b5064 100644 --- a/ingestion/src/metadata/orm_profiler/metrics/system/system.py +++ b/ingestion/src/metadata/orm_profiler/metrics/system/system.py @@ -322,15 +322,11 @@ def _( metric_results: List[Dict] = [] information_schema_query_history = """ - SELECT * FROM table(information_schema.query_history( - end_time_range_start=>to_timestamp_ltz(DATEADD(HOUR, -{decrement_start}, CURRENT_TIMESTAMP())), - end_time_range_end=>to_timestamp_ltz(DATEADD(HOUR, -{decrement_end}, CURRENT_TIMESTAMP())), - result_limit=>10000 - )) - WHERE QUERY_TYPE IN ('INSERT', 'MERGE', 'DELETE', 'UPDATE') - order by start_time DESC; + SELECT * FROM "SNOWFLAKE"."ACCOUNT_USAGE"."QUERY_HISTORY" + WHERE + start_time>= DATEADD('DAY', -1, CURRENT_TIMESTAMP) + AND QUERY_TYPE IN ('INSERT', 'MERGE', 'DELETE', 'UPDATE'); """ - result_scan = """ SELECT * FROM TABLE(RESULT_SCAN('{query_id}')); @@ -345,17 +341,7 @@ def _( # limit of results is 10K. We'll query range of 1 hours to make sure we # get all the necessary data. - for decrement in range(24): - cursor = session.execute( - text( - dedent( - information_schema_query_history.format( - decrement_start=decrement + 1, decrement_end=decrement - ) - ) - ) - ) - rows.extend(cursor.fetchall()) + rows = session.execute(text(information_schema_query_history)).fetchall() query_results = [ QueryResult(