Open yegorski opened 2 months ago
Actually ignore the SQL file I provided. It's redundant to your new Query History With Ratios
graph that uses the warehouse_query_history
materialized view. But my point still stands -- would be great to have cost number in the view so that that graph doesn't have to compute it on every load.
We're refactoring our monitoring dashboards to use the materialized views created in https://github.com/CodyAustinDavis/dbsql_sme/blob/main/Observability%20Dashboards%20and%20DBA%20Resources/Observability%20Lakeview%20Dashboard%20Templates/DBSQL%20Warehouse%20Advisor%20With%20Data%20Model/DBSQL%20Warehouse%20Advisor%20Data%20Model.sql
We're doing this so that our other query lookup code that sits on top is 1) DRY and 2) fast. (2) is the more important because right now the direct
system.query.history
lookups take up minutes to finish.I was sad to discover that the AllocatedQueryCostByTime column is not part of warehouse_query_history. We end up still needing to write this query (coped from an older version of the dashboard here) below. This extra query takes a long time to run as well.
Anyway, hope this makes sense. Happy to chat yegor.ius@enigma.com
PS: I was trying (still am) to add these extra filters to the materialized view. The issue is that the filters use date params (e.g. here
timestampdiff(SECOND, usage_start_time, :param_start_time) :: float AS seconds_before_start_range
) which are not allowed in materialized view creation. Any way around this?The specific filters that seem to be needed in order to add
AllocatedQueryCostByTime
are: