Account Usage

Account Usage (SNOWFLAKE 계정 사용량)

SNOWFLAKE 데이터베이스 안의 ACCOUNT_USAGE와 READER_ACCOUNT_USAGE 스키마를 사용하면, 계정과 계정에 연결된 모든 리더 계정(있는 경우)의 객체 메타데이터와 과거 사용량 데이터를 쿼리할 수 있어요. 이 페이지는 두 스키마가 어떤 역할을 하는지, 정보 스키마(Information Schema)와는 무엇이 다른지, 그리고 각 스키마에 어떤 뷰들이 있는지를 정리해요.

출처: Snowflake SQL Reference

본문

Account Usage 스키마 개요

ACCOUNT_USAGE:

계정의 객체 메타데이터와 사용량 지표를 표시하는 뷰들이에요.

일반적으로 이 뷰들은 Snowflake 정보 스키마(Snowflake Information Schema)의 해당 뷰와 테이블 함수를 반영하지만, 다음 차이점이 있어요.

  • 각 뷰에 드롭된 객체의 레코드가 포함돼요.
  • 과거 사용량 데이터의 보존 기간이 더 길어요.
  • 데이터 지연 시간(latency)이 있어요.

자세한 내용은 이 주제의 Account Usage와 Information Schema의 차이를 참고해요. 각 뷰에 대한 자세한 내용은 이 주제의 ACCOUNT_USAGE 뷰를 참고해요.

READER_ACCOUNT_USAGE:

계정(Secure Data Sharing 프로바이더로서)에 생성된 모든 리더 계정의 객체 메타데이터와 사용량 지표를 표시하는 뷰들이에요.

이 뷰들은 리더 계정에 적용되는 ACCOUNT_USAGE 뷰의 작은 부분집합이에요. 또한 이 스키마의 각 뷰에는 리더 계정별로 결과를 필터링하기 위한 추가 READER_ACCOUNT_NAME 컬럼이 있어요.

각 뷰에 대한 자세한 내용은 이 주제의 READER_ACCOUNT_USAGE 뷰를 참고해요.

계정에 생성된 리더 계정이 없으면 이 뷰들은 비어 있어요.

Account Usage와 Information Schema의 차이

Account Usage 뷰와 Snowflake Information Schema의 해당 뷰(또는 테이블 함수)는 동일한 구조와 명명 규칙을 사용하지만, 이 섹션에 설명된 몇 가지 핵심 차이점이 있어요.

차이점 Account Usage Information Schema
드롭된 객체 포함 아니요
데이터 지연 시간 45분~3시간(뷰마다 다름) 없음
과거 데이터 보존 1년 7일~6개월(뷰/테이블 함수마다 다름)

자세한 내용은 다음 섹션을 참고해요.

드롭된 객체 레코드

Account Usage 뷰는 드롭된 모든 객체의 레코드를 포함해요. 객체 유형의 많은 뷰에는 객체가 드롭된 시각을 표시하는 추가 DELETED 컬럼이 있어요.

또한 객체는 같은 이름으로 드롭되고 다시 생성될 수 있으므로, 같은 이름을 가진 객체 레코드를 구분하기 위해 account usage 뷰는 시스템이 각 레코드에 생성·할당한 내부 ID를 표시하는 ID 컬럼(적절한 경우)을 포함해요.

객체 이름 컬럼(예: TABLE_NAME 컬럼)이 NULL이면 그 객체는 드롭된 거예요. 이 경우 상위 객체의 이름과 ID 컬럼(예: DATABASE_NAME, SCHEMA_NAME 컬럼)도 NULL이에요.

일부 뷰에서는 객체가 드롭되었더라도 객체 이름 컬럼에 객체 이름이 여전히 포함될 수 있다는 점에 주의해요.

데이터 지연 시간

Snowflake 내부 메타데이터 저장소에서 데이터를 추출하는 과정 때문에 Account Usage 뷰는 자연스러운 지연 시간이 있어요.

  • 대부분의 뷰에서 지연 시간은 2시간(120분)이에요.
  • 나머지 뷰의 지연 시간은 45분에서 3시간까지 다양해요.

자세한 내용은 각 스키마의 뷰 목록(이 주제)을 참고해요. 또한 이것들은 모두 최대 시간 길이이며, 뷰를 쿼리할 때 특정 뷰의 실제 지연 시간은 더 짧을 수 있다는 점에 주의해요.

반면 Snowflake Information Schema의 뷰/테이블 함수는 지연 시간이 없어요.

과거 데이터 보존

일부 Account Usage 뷰는 과거 사용량 지표를 제공해요. 이 뷰들의 보존 기간은 1년(365일)이에요.

반면 Snowflake Information Schema의 해당 뷰와 테이블 함수는 뷰에 따라 7일에서 6개월까지의 훨씬 짧은 보존 기간을 가져요.

ACCOUNT_USAGE 뷰

ACCOUNT_USAGE 스키마에는 다음 뷰들이 있어요.

유형 지연 시간 [1] 에디션 [3] 비고
ACCESS_HISTORY Historical 3 hours Enterprise Edition (or higher) Data retained for 1 year.
AGGREGATE_ACCESS_HISTORY Historical 3 hours Enterprise Edition (or higher) Data retained for 1 year.
AGGREGATE_QUERY_HISTORY Historical 3 hours
AGGREGATION_POLICIES Object 2 hours
AI_GATEWAY_USAGE_HISTORY Historical Data retained for 1 year.
ALERT_HISTORY Historical 3 hours Data retained for 1 year.
ANOMALIES_DAILY Historical 3 hours Data retained for 1 year.
APPLICATION_CALLBACK_HISTORY Historical 3 hours Data retained for 1 year.
APPLICATION_CONFIGURATIONS Object 3 hours Data retained for 1 year.
APPLICATION_CONFIGURATION_VALUE_HISTORY Historical 3 hours Data retained for 1 year.
APPLICATION_DAILY_USAGE_HISTORY Historical 24 hours Data retained for 1 year.
APPLICATION_REMOTE_OPERATION_HISTORY Historical 1 hour Data retained for 1 year.
APPLICATION_SPECIFICATION_STATUS_HISTORY Historical 1 hour Data retained for 1 year.
APPLICATION_SPECIFICATIONS Historical 1 hour Data for deleted app specifications is retained for 1 year.
ARCHIVE_STORAGE_DATA_RETRIEVAL_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
AUTOMATIC_CLUSTERING_HISTORY Historical 3 hours Data retained for 1 year.
BACKUP_OPERATION_HISTORY Historical 6 hours Data retained for 1 year.
BACKUP_POLICIES Object 6 hours
BACKUP_SETS Object 6 hours
BACKUP_STORAGE_USAGE Historical 6 hours Data retained for 1 year.
BACKUPS Object 6 hours
BLOCK_STORAGE_HISTORY Historical 3 hours Data retained for 1 year.
BLOCK_STORAGE_SNAPSHOTS Object 3 hours
CATALOG_LINKED_DATABASE_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
CLASS_INSTANCES Object 3 hours Data retained for 1 year.
CLASSES Object 3 hours Data retained for 1 year.
COLUMN_QUERY_PRUNING_HISTORY Historical 4 hours Data retained for 1 year.
COLUMNS Object 90 minutes
COMPLETE_TASK_GRAPHS Historical 45 minutes Data retained for 1 year.
COMPUTE_POOLS Historical 3 hours Data retained for 1 year.
CONTACT_REFERENCES Object 3 hours
CONTACTS Object 3 hours
COPY_FILES_HISTORY Historical Data retained for 1 year.
COPY_HISTORY Historical 2 hours [2] Data retained for 1 year.
CORTEX_AGENT_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CORTEX_AI_FUNCTIONS_USAGE_HISTORY Historical Data retained for 1 year.
CORTEX_AI_GUARDRAILS_USAGE_HISTORY Historical Data retained for 1 year.
CORTEX_AISQL_USAGE_HISTORY Historical Data retained for 1 year.
CORTEX_CODE_CLI_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CORTEX_CODE_SNOWSIGHT_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CORTEX_ANALYST_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CORTEX_DOCUMENT_PROCESSING_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CORTEX_FINE_TUNING_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CORTEX_FUNCTIONS_QUERY_USAGE_HISTORY Historical Data retained for 1 year.
CORTEX_FUNCTIONS_USAGE_HISTORY Historical Data retained for 1 year.
CORTEX_PROVISIONED_THROUGHPUT_USAGE_HISTORY Historical Data retained for 1 year.
CORTEX_REST_API_RATE_LIMIT_POLICIES Object 6 hours
CORTEX_REST_API_USAGE_HISTORY Historical Data retained for 1 year.
CORTEX_SEARCH_BATCH_QUERY_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CORTEX_SEARCH_DAILY_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
CORTEX_SEARCH_SERVING_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
CREDENTIALS Object 2 hours
DATA_CLASSIFICATION_HISTORY Historical 3 hours Enterprise Edition (or higher) Data retained for 1 year.
DATA_CLASSIFICATION_LATEST Object 3 hours Enterprise Edition (or higher) Data retained for as long as the table exists.
DATA_METRIC_FUNCTION_EXPECTATIONS Object 30 minutes Enterprise Edition (or higher)
DATA_METRIC_FUNCTION_REFERENCES Object 3 hours Enterprise Edition (or higher)
DATA_MOVEMENT_POLICIES Object 2 hours
DATA_MOVEMENT_POLICY_RULES Object 2 hours
DATA_MOVEMENT_RULE_REFERENCES Historical 3 hours
DATA_MOVEMENT_VIOLATIONS Historical 3 hours Data is retained for one year.
DATA_QUALITY_MONITORING_USAGE_HISTORY Historical 3 hours Enterprise Edition (or higher) Data retained for 1 year.
DATABASES Object 3 hours
DATABASE_REPLICATION_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
DATABASE_STORAGE_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
DATA_TRANSFER_HISTORY Historical 2 hours Data retained for 1 year.
DBT_PROJECT_EXECUTION_HISTORY Historical 2 hours Data retained for 1 year.
DOCUMENT_AI_USAGE_HISTORY Historical Data retained for 1 year.
DYNAMIC_TABLE_REFRESH_HISTORY Historical 3 hours Data retained for 1 year.
ELEMENT_TYPES Object 90 minutes
EVENT_ROUTING_TABLES Object 2 hours
EVENT_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
EXTERNAL_ACCESS_HISTORY Historical 2 hours Data retained for 1 year.
FIELDS Object 90 minutes
FILE_FORMATS Object 2 hours
FUNCTIONS Object 2 hours
GRANTS_TO_ROLES Object 2 hours
GRANTS_TO_SHARES Object 3 hours
GRANTS_TO_USERS Object 2 hours
HYBRID_TABLES Object 3 hours
HYBRID_TABLE_USAGE_HISTORY Historical 3 hours Data retained for 1 year. (As of March 1, 2026, hybrid table requests are no longer billed, and metering was disabled soon after this pricing change took effect.)
ICEBERG_STORAGE_OPTIMIZATION_HISTORY Historical 2 hours Data retained for 1 year.
INDEX_COLUMNS Object 3 hours
INDEXES Object 3 hours
INGRESS_NETWORK_ACCESS_HISTORY Historical 4 hours Data retained for 1 year.
INTERNAL_DATA_TRANSFER_HISTORY Historical 3 hours
INTERNAL_STAGE_NETWORK_ACCESS_HISTORY Historical 6 hours Data retained for 1 year.
JOIN_POLICIES Object 2 hours
LISTINGS Object 3 hours
LOAD_HISTORY Historical 90 minutes [2] Data retained for 1 year.
LOCK_WAIT_HISTORY Historical 3 hours Data retained for 1 year.
LOGIN_HISTORY Historical 2 hours Data retained for 1 year.
MASKING_POLICIES Object 2 hours
MATERIALIZED_VIEW_REFRESH_HISTORY Historical 3 hours Enterprise Edition (or higher) Data retained for 1 year.
METERING_DAILY_HISTORY Historical 3 hours Data retained for 1 year.
METERING_HISTORY Historical 3 hours Data retained for 1 year.
MODEL_SERVING_USAGE_HISTORY Historical Data retained for 1 year.
NETWORK_POLICIES Object 2 hours
NETWORK_RULE_REFERENCES Object 2 hours
NETWORK_RULES Object 2 hours
NOTEBOOKS_CONTAINER_RUNTIME_HISTORY Historical 3 hours
OBJECT_ACCESS_REQUEST_HISTORY Historical 3 hours
OBJECT_DEPENDENCIES Historical 3 hours
ONLINE_FEATURE_TABLE_REFRESH_HISTORY Historical 3 hours
OPENFLOW_USAGE_HISTORY Historical 3 hours
OUTBOUND_PRIVATELINK_ENDPOINTS Object 2 hours Business Critical (or higher) Data for deleted endpoints is retained for 1 year.
PASSWORD_POLICIES Object 2 hours
PIPES Object 2 hours
PIPE_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
POLICY_REFERENCES Object 2 hours
POSTGRES_COMPUTE_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
POSTGRES_STORAGE_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
PRIVACY_BUDGETS Object 24 hours Enterprise Edition (or higher)
PRIVACY_POLICIES Object 2 hours Enterprise Edition (or higher)
PROCEDURES Object 2 hours
PROJECTION_POLICIES Object 2 hours
QUERY_ACCELERATION_ELIGIBLE Historical 3 hours Data retained for 1 year.
QUERY_ACCELERATION_HISTORY Historical 3 hours Enterprise Edition (or higher) Data retained for 1 year.
QUERY_ATTRIBUTION_HISTORY Historical 8 hours Data retained for 1 year.
QUERY_HISTORY Historical 45 minutes Data retained for 1 year.
QUERY_INSIGHTS Historical Data retained for 1 year.
QUERY_METERING_HISTORY Historical 1 hour Data retained for 1 year.
REFERENTIAL_CONSTRAINTS Object 2 hours
REPLICATION_GROUP_REFRESH_HISTORY Historical 3 hours Data retained for 1 year.
REPLICATION_GROUP_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
REPLICATION_GROUPS Object 2 hours
REPLICATION_USAGE_HISTORY Historical 3 hours Data retained for 1 year.
RESOURCE_MONITORS Object 2 hours
ROLES Object 2 hours
ROW_ACCESS_POLICIES Object 2 hours
SCHEMATA Object 2 hours
SEARCH_OPTIMIZATION_BENEFITS Historical 6 hours Enterprise Edition (or higher) Data retained for 1 year.
SEARCH_OPTIMIZATION_HISTORY Historical 3 hours Enterprise Edition (or higher) Data retained for 1 year.
SECRETS Object 2 hours
SEMANTIC_DIMENSIONS Object 2 hours
SEMANTIC_FACTS Object 2 hours
SEMANTIC_METRICS Object 2 hours
SEMANTIC_RELATIONSHIPS Object 2 hours
SEMANTIC_TABLES Object 2 hours
SEMANTIC_VIEWS Object 2 hours
SEQUENCES Object 2 hours
SERVERLESS_ALERT_HISTORY Historical 3 hours Data retained for 1 year.
SERVERLESS_TASK_HISTORY Historical 3 hours Data retained for 1 year.
SERVICES Object 3 hours
SESSION_POLICIES Object 2 hours
SESSIONS Historical 3 hours Data retained for 1 year.
SHARES Object 3 hours
SNAPSHOT_OPERATION_HISTORY Historical 6 hours Data retained for 1 year. This view is deprecated. Use the BACKUP_OPERATION_HISTORY view instead.
SNAPSHOT_POLICIES Object 6 hours This view is deprecated. Use the BACKUP_POLICIES view instead.
SNAPSHOT_SETS Object 6 hours This view is deprecated. Use the BACKUP_SETS view instead.
SNAPSHOT_STORAGE_USAGE Historical 6 hours Data retained for 1 year. This view is deprecated. Use the BACKUP_STORAGE_USAGE view instead.
SNAPSHOTS Object 6 hours This view is deprecated. Use the BACKUPS view instead.
SNOWFLAKE_APP_RUNTIME_COMPUTE_HISTORY Historical 3 hours Data retained for 1 year.
SNOWFLAKE_COCO_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
SNOWFLAKE_COWORK_USAGE_HISTORY Historical 1 hour Data retained for 1 year.
SNOWPARK_CONTAINER_SERVICES_HISTORY Historical 3 hours Data retained for 1 year.
SNOWPIPE_STREAMING_CHANNEL_HISTORY Historical
SNOWPIPE_STREAMING_CLIENT_HISTORY Historical 2 hours Data retained for 1 year.
SNOWPIPE_STREAMING_FILE_MIGRATION_HISTORY Historical 12 hours Data retained for 1 year.
STAGES Object 2 hours
STAGE_STORAGE_USAGE_HISTORY Historical 2 hours Data retained for 1 year.
STORAGE_LIFECYCLE_POLICIES Object 2 hours
STORAGE_LIFECYCLE_POLICY_HISTORY Historical 2 hours Data retained for 1 year.
STORAGE_REQUEST_HISTORY Historical 6 hours Data retained for 1 year.
STORAGE_USAGE Historical 2 hours Combined usage across all database tables and internal stages. Data retained for 1 year.
TABLES Object 90 minutes
TABLE_CONSTRAINTS Object 2 hours
TABLE_DML_HISTORY Historical 6 hours Data retained for 1 year.
TABLE_PRUNING_HISTORY Historical 6 hours Data retained for 1 year.
TABLE_QUERY_PRUNING_HISTORY Historical 4 hours Data retained for 1 year.
TABLE_STORAGE_METRICS Object 90 minutes
TAG_REFERENCES Object 2 hours
TAGS Object 2 hours
TASK_HISTORY Historical 45 minutes
TASK_VERSIONS Object 3 hours
TRI_SECRET_SECURE_HISTORY Historical 2 hours
TRUST_CENTER_FINDINGS Historical 1 hour
TYPES Object 2 hours
USERS Object 2 hours
VIEWS Object 90 minutes
WAREHOUSE_EVENTS_HISTORY Historical 3 hours Data retained for 1 year.
WAREHOUSE_LOAD_HISTORY Historical 3 hours Data retained for 1 year.
WAREHOUSE_METERING_HISTORY Historical 3 hours Data retained for 1 year.

[1] 모든 지연 시간은 근사치이며 실제 지연 시간은 더 낮을 수 있어요.

[2] 다음 두 조건이 모두 true이면 특정 테이블의 뷰 지연 시간이 최대 2일일 수 있어요: 1. 주어진 테이블이 LOAD_HISTORY 또는 COPY_HISTORY에서 마지막으로 업데이트된 이후 DML 문이 32개 미만 추가됨. 2. 주어진 테이블이 LOAD_HISTORY 또는 COPY_HISTORY에서 마지막으로 업데이트된 이후 행이 100개 미만 추가됨.

[3] 달리 명시되지 않는 한 Account Usage 뷰는 모든 계정에서 사용할 수 있어요.

Account Usage 테이블 함수

현재 Snowflake는 하나의 ACCOUNT_USAGE 테이블 함수를 지원해요.

테이블 함수 데이터 보존 비고
TAG_REFERENCES_WITH_LINEAGE 해당 없음 결과는 지정된 객체에 접근 권한이 있는 역할에 대해서만 반환돼요.

Note

Account Usage 뷰와 마찬가지로 이 테이블 함수를 호출할 때도 지연 시간을 고려해야 해요. 이 테이블 함수의 예상 지연 시간은 TAG_REFERENCES 뷰의 지연 시간과 비슷해요.

READER_ACCOUNT_USAGE 뷰

READER_ACCOUNT_USAGE 스키마에는 다음 뷰들이 있어요.

유형 지연 시간 [1] 비고
LOGIN_HISTORY Historical 2 hours Data retained for 1 year.
QUERY_HISTORY Historical 45 minutes Data retained for 1 year.
RESOURCE_MONITORS Object 2 hours
STORAGE_USAGE Historical 24 hours Combined usage across all database tables and internal stages. Data retained for 1 year.
WAREHOUSE_METERING_HISTORY Historical 24 hours Data retained for 1 year.

[1] 모든 지연 시간은 근사치이며 실제 지연 시간은 더 낮을 수 있어요.

SNOWFLAKE 데이터베이스에서 다른 역할이 스키마를 사용하도록 활성화하기

기본적으로 SNOWFLAKE 데이터베이스는 모든 사용자에게 표시돼요. 그러나 이 데이터베이스의 스키마에 대한 접근은 ACCOUNTADMIN 역할을 가진 사용자가 다음 방법 중 하나로 부여할 수 있어요.

  • SNOWFLAKE 데이터베이스에 IMPORTED PRIVILEGES 부여.
  • 계정 역할에 SNOWFLAKE 데이터베이스 역할 부여.

중요

의도치 않게 조직 수준 데이터에 접근을 부여하지 않으려면, ACCOUNT_USAGE 스키마의 뷰에 접근을 부여할 때 SNOWFLAKE 데이터베이스 역할 사용을 고려해요.

자세한 내용은 GRANT DATABASE ROLE을 참고해요.

예를 들어 SNOWFLAKE 데이터베이스에 두 역할에 대해 IMPORTED PRIVILEGES를 부여하려면:

USE ROLE ACCOUNTADMIN;

GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE SYSADMIN;
GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE TO ROLE customrole1;

customrole1 역할이 부여된 사용자는 다음과 같이 뷰를 쿼리할 수 있어요.

USE ROLE customrole1;

SELECT database_name, database_owner FROM SNOWFLAKE.ACCOUNT_USAGE.DATABASES;

추가 예제는 Account Usage 뷰 쿼리하기를 참고해요.

ACCOUNT_USAGE 스키마 SNOWFLAKE 데이터베이스 역할

또한 SNOWFLAKE 데이터베이스 역할로 계정에 더 세밀한 제어를 부여할 수 있어요. 데이터베이스 역할에 대한 자세한 내용은 데이터베이스 역할을 참고해요.

ACCOUNT_USAGE 스키마에는 정의된 4개의 SNOWFLAKE 데이터베이스 역할이 있으며, 각 역할은 특정 뷰에 SELECT 권한이 부여돼요.

역할 목적과 설명
OBJECT_VIEWER OBJECT_VIEWER 역할은 객체 메타데이터에 대한 가시성을 제공해요.
USAGE_VIEWER USAGE_VIEWER 역할은 과거 사용량 정보에 대한 가시성을 제공해요.
GOVERNANCE_VIEWER GOVERNANCE_VIEWER 역할은 데이터 거버넌스 관련 정보에 대한 가시성을 제공해요.
SECURITY_VIEWER SECURITY_VIEWER 역할은 보안 기반 정보에 대한 가시성을 제공해요.

ACCOUNT_USAGE 뷰에 접근하는 데 필요한 데이터베이스 역할

OBJECT_VIEWER, USAGE_VIEWER, GOVERNANCE_VIEWER, SECURITY_VIEWER 역할은 공유 SNOWFLAKE 데이터베이스에서 Account Usage 뷰를 쿼리할 SELECT 권한을 가져요. 다음 표를 사용해 어떤 데이터베이스 역할이 어떤 뷰에 접근할 수 있는지 확인해요.

데이터베이스 역할
ACCESS_HISTORY view GOVERNANCE_VIEWER
AGGREGATE_ACCESS_HISTORY view GOVERNANCE_VIEWER
AGGREGATE_QUERY_HISTORY view GOVERNANCE_VIEWER
AGGREGATION_POLICIES view GOVERNANCE_VIEWER
ANOMALIES_DAILY view USAGE_VIEWER
APPLICATION_CALLBACK_HISTORY view SECURITY_VIEWER
APPLICATION_CONFIGURATIONS view SECURITY_VIEWER
APPLICATION_CONFIGURATION_VALUE_HISTORY view SECURITY_VIEWER
APPLICATION_DAILY_USAGE_HISTORY view USAGE_VIEWER
APPLICATION_SPECIFICATION_STATUS_HISTORY view SECURITY_VIEWER
APPLICATION_SPECIFICATIONS view SECURITY_VIEWER
ARCHIVE_STORAGE_DATA_RETRIEVAL_USAGE_HISTORY view USAGE_VIEWER
AUTOMATIC_CLUSTERING_HISTORY view USAGE_VIEWER
BLOCK_STORAGE_HISTORY view USAGE_VIEWER
BLOCK_STORAGE_SNAPSHOTS view OBJECT_VIEWER
CATALOG_LINKED_DATABASE_USAGE_HISTORY view USAGE_VIEWER
CLASS_INSTANCES view USAGE_VIEWER
CLASSES view USAGE_VIEWER
COLUMN_QUERY_PRUNING_HISTORY view USAGE_VIEWER
COLUMNS view OBJECT_VIEWER
COMPLETE_TASK_GRAPHS view OBJECT_VIEWER
CONTACT_REFERENCES view GOVERNANCE_VIEWER
CONTACTS view GOVERNANCE_VIEWER
COPY_FILES_HISTORY view USAGE_VIEWER
COPY_HISTORY view USAGE_VIEWER
CORTEX_AGENT_USAGE_HISTORY view USAGE_VIEWER
CORTEX_AI_FUNCTIONS_USAGE_HISTORY view USAGE_VIEWER
CORTEX_AI_GUARDRAILS_USAGE_HISTORY view USAGE_VIEWER
CORTEX_AISQL_USAGE_HISTORY view USAGE_VIEWER
CORTEX_ANALYST_USAGE_HISTORY view USAGE_VIEWER
CORTEX_DOCUMENT_PROCESSING_USAGE_HISTORY view USAGE_VIEWER
CORTEX_FINE_TUNING_USAGE_HISTORY view USAGE_VIEWER
CORTEX_FUNCTIONS_QUERY_USAGE_HISTORY view USAGE_VIEWER
CORTEX_FUNCTIONS_USAGE_HISTORY view USAGE_VIEWER
CORTEX_PROVISIONED_THROUGHPUT_USAGE_HISTORY view USAGE_VIEWER
CORTEX_REST_API_USAGE_HISTORY view USAGE_VIEWER
CORTEX_SEARCH_BATCH_QUERY_USAGE_HISTORY view USAGE_VIEWER
CORTEX_SEARCH_DAILY_USAGE_HISTORY view USAGE_VIEWER
CORTEX_SEARCH_SERVING_USAGE_HISTORY view USAGE_VIEWER
CREDENTIALS view SECURITY_VIEWER
DATA_CLASSIFICATION_HISTORY view GOVERNANCE_VIEWER
DATA_CLASSIFICATION_LATEST view GOVERNANCE_VIEWER
DATA_METRIC_FUNCTION_EXPECTATIONS view USAGE_VIEWER or GOVERNANCE_VIEWER
DATA_METRIC_FUNCTION_REFERENCES view USAGE_VIEWER or GOVERNANCE_VIEWER
DATA_QUALITY_MONITORING_USAGE_HISTORY view USAGE_VIEWER
DATA_TRANSFER_HISTORY view USAGE_VIEWER
DATABASE_STORAGE_USAGE_HISTORY view USAGE_VIEWER
DATABASES view OBJECT_VIEWER
DOCUMENT_AI_USAGE_HISTORY view USAGE_VIEWER
DYNAMIC_TABLE_REFRESH_HISTORY view USAGE_VIEWER
ELEMENT_TYPES view OBJECT_VIEWER
EVENT_USAGE_HISTORY view USAGE_VIEWER
EXTERNAL_ACCESS_HISTORY view USAGE_VIEWER
FIELDS view OBJECT_VIEWER
FILE_FORMATS view OBJECT_VIEWER
FUNCTIONS view OBJECT_VIEWER
GRANTS_TO_ROLES view SECURITY_VIEWER
GRANTS_TO_SHARES view SECURITY_VIEWER
GRANTS_TO_USERS view SECURITY_VIEWER
HYBRID_TABLE_USAGE_HISTORY view USAGE_VIEWER
HYBRID_TABLES view OBJECT_VIEWER
ICEBERG_STORAGE_OPTIMIZATION_HISTORY view USAGE_VIEWER
INDEX_COLUMNS view OBJECT_VIEWER
INDEXES view OBJECT_VIEWER
INGRESS_NETWORK_ACCESS_HISTORY view SECURITY_VIEWER
INTERNAL_DATA_TRANSFER_HISTORY view USAGE_VIEWER
INTERNAL_STAGE_NETWORK_ACCESS_HISTORY view SECURITY_VIEWER
JOIN_POLICIES view GOVERNANCE_VIEWER
LISTINGS view SECURITY_VIEWER
LOAD_HISTORY view USAGE_VIEWER
LOGIN_HISTORY view SECURITY_VIEWER
MASKING_POLICIES view GOVERNANCE_VIEWER
MATERIALIZED_VIEW_REFRESH_HISTORY view USAGE_VIEWER
METERING_DAILY_HISTORY view USAGE_VIEWER
METERING_HISTORY view USAGE_VIEWER
MODEL_SERVING_USAGE_HISTORY view USAGE_VIEWER
NETWORK_POLICIES view SECURITY_VIEWER
NETWORK_RULE_REFERENCES view SECURITY_VIEWER
NETWORK_RULES view SECURITY_VIEWER
NOTEBOOKS_CONTAINER_RUNTIME_HISTORY view USAGE_VIEWER
OBJECT_ACCESS_REQUEST_HISTORY view OBJECT_VIEWER
OBJECT_DEPENDENCIES view OBJECT_VIEWER
ONLINE_FEATURE_TABLE_REFRESH_HISTORY view USAGE_VIEWER
OPENFLOW_USAGE_HISTORY view USAGE_VIEWER
OUTBOUND_PRIVATELINK_ENDPOINTS view SECURITY_VIEWER
PASSWORD_POLICIES view SECURITY_VIEWER
PIPE_USAGE_HISTORY view USAGE_VIEWER
PIPES view OBJECT_VIEWER
POLICY_REFERENCES view GOVERNANCE_VIEWER, SECURITY_VIEWER
POSTGRES_COMPUTE_USAGE_HISTORY view USAGE_VIEWER
POSTGRES_STORAGE_USAGE_HISTORY view USAGE_VIEWER
PRIVACY_BUDGETS view GOVERNANCE_VIEWER
PRIVACY_POLICIES view GOVERNANCE_VIEWER
PROCEDURES view OBJECT_VIEWER
PROJECTION_POLICIES view GOVERNANCE_VIEWER
QUERY_ACCELERATION_ELIGIBLE view GOVERNANCE_VIEWER
QUERY_ATTRIBUTION_HISTORY view USAGE_VIEWER, GOVERNANCE_VIEWER
QUERY_HISTORY view GOVERNANCE_VIEWER
QUERY_INSIGHTS view GOVERNANCE_VIEWER
QUERY_METERING_HISTORY view USAGE_VIEWER, GOVERNANCE_VIEWER
REFERENTIAL_CONSTRAINTS view OBJECT_VIEWER
REPLICATION_GROUP_REFRESH_HISTORY view USAGE_VIEWER
REPLICATION_GROUP_USAGE_HISTORY view USAGE_VIEWER
REPLICATION_GROUPS view OBJECT_VIEWER
REPLICATION_USAGE_HISTORY view USAGE_VIEWER
RESOURCE_MONITORS view OBJECT_VIEWER
ROLES view SECURITY_VIEWER
ROW_ACCESS_POLICIES view GOVERNANCE_VIEWER
SCHEMATA view OBJECT_VIEWER
SEARCH_OPTIMIZATION_BENEFITS view USAGE_VIEWER
SEARCH_OPTIMIZATION_HISTORY view USAGE_VIEWER
SECRETS view SECURITY_VIEWER
SEMANTIC_DIMENSIONS view OBJECT_VIEWER
SEMANTIC_FACTS view OBJECT_VIEWER
SEMANTIC_METRICS view OBJECT_VIEWER
SEMANTIC_RELATIONSHIPS view OBJECT_VIEWER
SEMANTIC_TABLES view OBJECT_VIEWER
SEMANTIC_VIEWS view OBJECT_VIEWER
SEQUENCES view OBJECT_VIEWER
SERVERLESS_ALERT_HISTORY view USAGE_VIEWER
SERVERLESS_TASK_HISTORY view USAGE_VIEWER
SERVICES view OBJECT_VIEWER
SESSION_POLICIES view SECURITY_VIEWER
SESSIONS view SECURITY_VIEWER
SHARES view SECURITY_VIEWER
SNAPSHOT_OPERATION_HISTORY view --- Deprecated OBJECT_VIEWER
SNAPSHOT_POLICIES view --- Deprecated OBJECT_VIEWER
SNAPSHOT_SETS view --- Deprecated OBJECT_VIEWER
SNAPSHOT_STORAGE_USAGE view --- Deprecated OBJECT_VIEWER
SNAPSHOTS view — Deprecated OBJECT_VIEWER
SNOWFLAKE_COCO_USAGE_HISTORY view USAGE_VIEWER
SNOWFLAKE_COWORK_USAGE_HISTORY view USAGE_VIEWER
SNOWPARK_CONTAINER_SERVICES_HISTORY view USAGE_VIEWER
SNOWPIPE_STREAMING_CHANNEL_HISTORY view USAGE_VIEWER
STAGE_STORAGE_USAGE_HISTORY view USAGE_VIEWER
STAGES view OBJECT_VIEWER
STORAGE_LIFECYCLE_POLICIES view GOVERNANCE_VIEWER
STORAGE_LIFECYCLE_POLICY_HISTORY view GOVERNANCE_VIEWER
STORAGE_REQUEST_HISTORY view USAGE_VIEWER
STORAGE_USAGE view USAGE_VIEWER
TABLE_CONSTRAINTS view OBJECT_VIEWER
TABLE_DML_HISTORY view USAGE_VIEWER
TABLE_PRUNING_HISTORY view USAGE_VIEWER
TABLE_QUERY_PRUNING_HISTORY view USAGE_VIEWER
TABLE_STORAGE_METRICS view USAGE_VIEWER
TABLES view OBJECT_VIEWER
TAG_REFERENCES view GOVERNANCE_VIEWER
TAGS view OBJECT_VIEWER or GOVERNANCE_VIEWER
TASK_HISTORY view USAGE_VIEWER
TASKS view OBJECT_VIEWER
TRUST_CENTER_FINDINGS view SECURITY_VIEWER
USERS view SECURITY_VIEWER
VIEWS view OBJECT_VIEWER
WAREHOUSE_EVENTS_HISTORY view USAGE_VIEWER
WAREHOUSE_LOAD_HISTORY view USAGE_VIEWER
WAREHOUSE_METERING_HISTORY view USAGE_VIEWER

READER_ACCOUNT_USAGE 스키마 SNOWFLAKE 데이터베이스 역할

READER_USAGE_VIEWER SNOWFLAKE 데이터베이스 역할은 모든 READER_ACCOUNT_USAGE 뷰에 SELECT 권한이 부여돼요. 리더 계정은 클라이언트가 만들므로, READER_USAGE_VIEWER 역할은 리더 계정 사용을 모니터링하는 데 사용되는 역할에 부여될 것으로 기대돼요.

LOGIN_HISTORY 뷰
QUERY_HISTORY 뷰
RESOURCE_MONITORS 뷰
STORAGE_USAGE 뷰
WAREHOUSE_METERING_HISTORY 뷰

Account Usage 뷰 쿼리하기

이 섹션은 Account Usage 뷰를 쿼리할 때의 고려 사항과 쿼리 예제를 포함해요.

컬럼 선택

Snowflake 특정 뷰들은 변경될 수 있어요. 이 뷰들에서 모든 컬럼을 선택하는 것은 피하고, 원하는 컬럼만 선택하세요. 예를 들어 name 컬럼이 필요하다면 SELECT * 대신 SELECT name을 사용해요.

비용 뷰 조정(Reconciling)

compute 리소스, 저장, 데이터 전송 비용과 관련된 데이터를 포함한 여러 Account Usage 뷰가 있어요. 이러한 뷰를 ORGANIZATION_USAGE 스키마의 해당 뷰와 조정하려면 먼저 세션 시간대를 UTC로 설정해야 해요.

예를 들어 ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY를 ORGANIZATION_USAGE.WAREHOUSE_METERING_HISTORY의 계정 데이터와 조정하려면, Account Usage 뷰를 쿼리하기 전에 다음 명령을 실행해야 해요.

ALTER SESSION SET TIMEZONE = UTC;

예제

다음 예제들은 ACCOUNT_USAGE 스키마의 뷰를 사용한 일반적/유용한 쿼리를 보여 줘요.

Note

  • 이 예제들은 현재 세션에서 SNOWFLAKE 데이터베이스와 ACCOUNT_USAGE 스키마가 사용 중이라고 가정해요. 또한 ACCOUNTADMIN 역할(또는 데이터베이스에 IMPORTED PRIVILEGES가 부여된 역할)이 사용 중이라고 가정해요. 사용 중이 아니라면 예제의 쿼리를 실행하기 전에 다음 명령을 실행해요.
USE ROLE ACCOUNTADMIN;

USE SCHEMA snowflake.account_usage;
예제: 사용자 로그인 지표

사용자별 실패한 로그인 시도 사이의 평균 초(월 누계, month-to-date):

select user_name,
       count(*) as failed_logins,
       avg(seconds_between_login_attempts) as average_seconds_between_login_attempts
from (
      select user_name,
             timediff(seconds, event_timestamp, lead(event_timestamp)
                 over(partition by user_name order by event_timestamp)) as seconds_between_login_attempts
      from login_history
      where event_timestamp > date_trunc(month, current_date)
      and is_success = 'NO'
     )
group by 1
order by 3;

사용자별 실패한 로그인(월 누계):

select user_name,
       sum(iff(is_success = 'NO', 1, 0)) as failed_logins,
       count(*) as logins,
       sum(iff(is_success = 'NO', 1, 0)) / nullif(count(*), 0) as login_failure_rate
from login_history
where event_timestamp > date_trunc(month, current_date)
group by 1
order by 4 desc;

사용자와 연결 클라이언트별 실패한 로그인(월 누계):

select reported_client_type,
       user_name,
       sum(iff(is_success = 'NO', 1, 0)) as failed_logins,
       count(*) as logins,
       sum(iff(is_success = 'NO', 1, 0)) / nullif(count(*), 0) as login_failure_rate
from login_history
where event_timestamp > date_trunc(month, current_date)
group by 1,2
order by 5 desc;
예제: 웨어하우스 성능

이 쿼리는 하루 동안 15분 간격으로 가상 웨어하우스 성능 지표(처리량과 지연 시간 등)를 계산해요.

아래 코드 샘플에서 CURRENT_WAREHOUSE()를 웨어하우스 이름으로 바꾸면 해당 웨어하우스의 지표를 계산할 수 있어요. 또한 WITH 절의 time_fromtime_to 날짜를 변경해 시간 기간을 지정해요.

WITH
params AS (
SELECT
    CURRENT_WAREHOUSE() AS warehouse_name,
    '2021-11-01' AS time_from,
    '2021-11-02' AS time_to
),

jobs AS (
SELECT
    query_id,
    time_slice(start_time::timestamp_ntz, 15, 'minute','start') as interval_start,
    qh.warehouse_name,
    database_name,
    query_type,
    total_elapsed_time,
    compilation_time AS compilation_and_scheduling_time,
    (queued_provisioning_time + queued_repair_time + queued_overload_time) AS queued_time,
    transaction_blocked_time,
    execution_time
FROM snowflake.account_usage.query_history qh, params
WHERE
    qh.warehouse_name = params.warehouse_name
AND start_time >= params.time_from
AND start_time <= params.time_to
AND execution_status = 'SUCCESS'
AND query_type IN ('SELECT','UPDATE','INSERT','MERGE','DELETE')
),

interval_stats AS (
SELECT
    query_type,
    interval_start,
    COUNT(DISTINCT query_id) AS numjobs,
    MEDIAN(total_elapsed_time)/1000 AS p50_total_duration,
    (percentile_cont(0.95) within group (order by total_elapsed_time))/1000 AS p95_total_duration,
    SUM(total_elapsed_time)/1000 AS sum_total_duration,
    SUM(compilation_and_scheduling_time)/1000 AS sum_compilation_and_scheduling_time,
    SUM(queued_time)/1000 AS sum_queued_time,
    SUM(transaction_blocked_time)/1000 AS sum_transaction_blocked_time,
    SUM(execution_time)/1000 AS sum_execution_time,
    ROUND(sum_compilation_and_scheduling_time/sum_total_duration,2) AS compilation_and_scheduling_ratio,
    ROUND(sum_queued_time/sum_total_duration,2) AS queued_ratio,
    ROUND(sum_transaction_blocked_time/sum_total_duration,2) AS blocked_ratio,
    ROUND(sum_execution_time/sum_total_duration,2) AS execution_ratio,
    ROUND(sum_total_duration/numjobs,2) AS total_duration_perjob,
    ROUND(sum_compilation_and_scheduling_time/numjobs,2) AS compilation_and_scheduling_perjob,
    ROUND(sum_queued_time/numjobs,2) AS queued_perjob,
    ROUND(sum_transaction_blocked_time/numjobs,2) AS blocked_perjob,
    ROUND(sum_execution_time/numjobs,2) AS execution_perjob
FROM jobs
GROUP BY 1,2
ORDER BY 1,2
)
SELECT * FROM interval_stats;

Note

다른 문 유형을 별도로 분석해요(예: SELECT 문은 INSERT나 DELETE 또는 다른 문과 독립적으로).

  • NUMJOBS 값은 해당 시간 간격의 처리량을 나타내요.
  • P50_TOTAL_DURATION(중앙값)과 P95_TOTAL_DURATION(피크) 값은 지연 시간을 나타내요.
  • SUM_TOTAL_DURATION은 다른 작업 단계(COMPILATION_AND_SCHEDULING, QUEUED, BLOCKED, EXECUTION)에 대한 SUM_<job_stage>_TIME 값들의 합이에요.
  • 부하(NUMJOBS)가 증가할 때 <job_stage>_RATIO 값을 분석해요. 평균에서 비율이 변하거나 벗어나는지 살펴봐요.
  • QUEUED_RATIO가 높다면 웨어하우스 용량이 충분하지 않을 수 있어요. 클러스터를 더 추가하거나 웨어하우스 크기를 늘려요.
예제: 웨어하우스 크레딧 사용량

계정의 각 웨어하우스가 사용한 크레딧(월 누계):

select warehouse_name,
       sum(credits_used) as total_credits_used
from warehouse_metering_history
where start_time >= date_trunc(month, current_date)
group by 1
order by 2 desc;

시간에 따른 계정 각 웨어하우스의 크레딧 사용량(월 누계):

select start_time::date as usage_date,
       warehouse_name,
       sum(credits_used) as total_credits_used
from warehouse_metering_history
where start_time >= date_trunc(month, current_date)
group by 1,2
order by 2,1;
예제: 데이터 저장 사용량

시간에 따른 계정의 청구 가능 테라바이트:

select date_trunc(month, usage_date) as usage_month
  , avg(storage_bytes + stage_bytes + failsafe_bytes) / power(1024, 4) as billable_tb
from storage_usage
group by 1
order by 1;
예제: 사용자 쿼리 합계와 실행 시간

계정에서 실행된 총 작업 수(월 누계):

select count(*) as number_of_jobs
from query_history
where start_time >= date_trunc(month, current_date);

계정의 각 웨어하우스별 실행된 총 작업 수(월 누계):

select warehouse_name,
       count(*) as number_of_jobs
from query_history
where start_time >= date_trunc(month, current_date)
group by 1
order by 2 desc;

사용자별 평균 쿼리 실행 시간(월 누계):

select user_name,
       avg(execution_time) as average_execution_time
from query_history
where start_time >= date_trunc(month, current_date)
group by 1
order by 2 desc;

쿼리 유형과 웨어하우스 크기별 평균 쿼리 실행 시간(월 누계):

select query_type,
       warehouse_size,
       avg(execution_time) as average_execution_time
from query_history
where start_time >= date_trunc(month, current_date)
group by 1,2
order by 3 desc;
예제: 각 로그인 이벤트에 대한 쿼리 수 얻기

LOGIN_HISTORY, QUERY_HISTORY, SESSIONS의 컬럼을 조인해 각 사용자 로그인 이벤트에 대한 쿼리 수를 얻어요.

Note

SESSIONS 뷰는 2020년 7월 20~21일부터 정보를 기록하므로, 쿼리 결과는 이 날짜부터 세 뷰 각각에 대해 겹치는 정보만 포함해요.

select l.user_name,
       l.event_timestamp as login_time,
       l.client_ip,
       l.reported_client_type,
       l.first_authentication_factor,
       l.second_authentication_factor,
       count(q.query_id)
from snowflake.account_usage.login_history l
join snowflake.account_usage.sessions s on l.event_id = s.login_event_id
join snowflake.account_usage.query_history q on q.session_id = s.session_id
group by 1,2,3,4,5,6
order by l.user_name
;

더 알아보기 (Learn more)