Changelog

SQL activity log

11.09.2023

Organization administrators can now access the history of SQL statements run against Materialize using the new mz_internal.mz_recent_activity_log system catalog view. This allows performing database administration tasks like identifying slow or long-running queries, monitoring query performance SLAs, and analyzing access patterns.

1
-- Say you have an SLA of "queries return under 3 seconds", and want to look
2
-- into any statements that don't comply. 🦥
3
SELECT
4
    sql,
5
    application_name,
6
    cluster_name,
7
    rows_returned,
8
    (finished_at - began_at) AS execution_time,
9
    finished_status
10
FROM mz_internal.mz_recent_activity_log
11
WHERE (finished_at - began_at) > INTERVAL '3 seconds'
12
ORDER BY execution_time DESC;
sql

In the future, the activity log will also be exposed in the Materialize console, so it's easier to access.