Skip to content

query_history: Reduce amount of indexed data down to 1 day #31250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/user/content/sql/system-catalog/mz_internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Entries in this view may be cleared on restart (e.g., during Materialize mainten
{{< /warning >}}

The `mz_recent_activity_log` view contains a log of the SQL statements
that have been issued to Materialize in the last three days, along
that have been issued to Materialize in the last 24 hours, along
with various metadata about them.

Entries in this log may be sampled. The sampling rate is controlled by
Expand Down
11 changes: 8 additions & 3 deletions src/catalog/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,12 @@ pub static MZ_PREPARED_STATEMENT_HISTORY: LazyLock<BuiltinSource> =
data_source: IntrospectionType::PreparedStatementHistory,
desc: MZ_PREPARED_STATEMENT_HISTORY_DESC.clone(),
is_retained_metrics_object: false,
access: vec![MONITOR_SELECT],
access: vec![
SUPPORT_SELECT,
ANALYTICS_SELECT,
MONITOR_REDACTED_SELECT,
MONITOR_SELECT,
],
});

pub static MZ_SQL_TEXT: LazyLock<BuiltinSource> = LazyLock::new(|| BuiltinSource {
Expand Down Expand Up @@ -3133,8 +3138,8 @@ pub static MZ_RECENT_ACTIVITY_LOG_THINNED: LazyLock<BuiltinView> = LazyLock::new
oid: oid::VIEW_MZ_RECENT_ACTIVITY_LOG_THINNED_OID,
column_defs: None,
sql:
"SELECT * FROM mz_internal.mz_activity_log_thinned WHERE prepared_at + INTERVAL '3 days' > mz_now()
AND began_at + INTERVAL '3 days' > mz_now()",
"SELECT * FROM mz_internal.mz_activity_log_thinned WHERE prepared_at + INTERVAL '1 day' > mz_now()
AND began_at + INTERVAL '1 day' > mz_now()",
access: vec![MONITOR_SELECT],
}
});
Expand Down
10 changes: 8 additions & 2 deletions test/sqllogictest/privilege_grants.slt
Original file line number Diff line number Diff line change
Expand Up @@ -4745,6 +4745,7 @@ mz_system,mz_monitor,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,
mz_system,mz_support,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_notices_redacted,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_support,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_recent_activity_log_thinned,SELECT,NO,YES
Expand All @@ -4753,16 +4754,18 @@ mz_system,mz_monitor,materialize,mz_internal,mz_statement_lifecycle_history,SELE
mz_system,mz_support,materialize,mz_internal,mz_statement_lifecycle_history,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_support,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_statement_lifecycle_history,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
mz_system,mz_support,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_statement_lifecycle_history,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
COMPLETE 46
COMPLETE 49

simple conn=mz_system,user=mz_system
SELECT COUNT(*) >= 166 FROM information_schema.table_privileges WHERE grantee = 'PUBLIC'
Expand Down Expand Up @@ -4820,6 +4823,7 @@ mz_system,mz_monitor,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,
mz_system,mz_support,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_notices_redacted,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_support,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_recent_activity_log_thinned,SELECT,NO,YES
Expand All @@ -4828,16 +4832,18 @@ mz_system,mz_monitor,materialize,mz_internal,mz_statement_lifecycle_history,SELE
mz_system,mz_support,materialize,mz_internal,mz_statement_lifecycle_history,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_support,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_statement_lifecycle_history,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_recent_sql_text_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_prepared_statement_history,SELECT,NO,YES
mz_system,mz_monitor,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
mz_system,mz_support,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_statement_lifecycle_history,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_recent_activity_log_redacted,SELECT,NO,YES
mz_system,mz_analytics,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
mz_system,mz_monitor_redacted,materialize,mz_internal,mz_statement_execution_history_redacted,SELECT,NO,YES
COMPLETE 46
COMPLETE 49

simple conn=mz_system,user=mz_system
SELECT COUNT(*) >= 166 FROM information_schema.role_table_grants WHERE grantee = 'PUBLIC'
Expand Down