SYS_LOAD_HISTORY
SYS_LOAD_HISTORY를 사용하여 COPY 명령의 세부 정보를 봅니다. 각 행은 일부 필드에 대한 누적 통계가 있는 COPY 명령을 나타냅니다. 여기에는 실행 중인 COPY 명령과 완료된 COPY 명령이 모두 포함됩니다.
SYS_LOAD_HISTORY는 모든 사용자에게 표시됩니다. 수퍼유저는 모든 행을 볼 수 있지만 일반 사용자는 자체 데이터만 볼 수 있습니다. 자세한 내용은 시스템 테이블 및 뷰에 있는 데이터의 가시성 섹션을 참조하세요.
테이블 열
열 명칭 | 데이터 유형 | 설명 |
---|---|---|
user_id | 정수 | 사본을 제출한 사용자의 식별자입니다. |
query_id | bigint | 사본의 쿼리 식별자입니다. |
transaction_id | bigint | 트랜잭션 식별자입니다. |
session_id | 정수 | 사본을 실행하는 프로세스의 프로세스 식별자입니다. |
database_name | 텍스트 | 작업이 실행되었을 때 사용자가 연결된 데이터베이스의 이름입니다. |
status | 텍스트 | 복사본의 상태입니다. 유효한 값은 running , completed , aborted 입니다. |
table_name | 텍스트 | 복사할 테이블의 이름입니다. |
start_time | 타임스탬프 | 복사가 시작된 시간입니다. |
end_time | 타임스탬프 | 복사가 완료된 시간입니다. |
duration | bigint | COPY 명령에 소요된 시간(마이크로초)입니다. |
data_source | 텍스트 | 복사할 파일 입력의 Amazon S3 위치입니다. |
file_format | 텍스트 | 소스 파일 형식입니다. 형식으로는 csv, txt, json, avro, orc, parquet 등이 있습니다. |
loaded_rows | bigint | 테이블에 복사된 행 수입니다. |
loaded_bytes | bigint | 테이블에 복사된 바이트 수입니다. |
source_file_count | 정수 | 소스 파일의 파일 수입니다. |
source_file_bytes | bigint | 소스 파일의 바이트 수입니다. |
file_count_scanned | 정수 | Amazon S3에서 스캔한 파일 수입니다. |
file_bytes_scanned | bigint | Amazon S3의 파일에서 스캔한 바이트 수입니다. |
error_count | bigint | 오류 수입니다. |
copy_job_id | bigint | 복사 작업 식별자입니다. 0 은 작업 식별자가 없음을 나타냅니다. |
샘플 쿼리
다음 쿼리는 특정 copy 명령의 로드된 행, 바이트 수, 테이블 및 데이터 소스를 보여줍니다.
SELECT query_id,
table_name,
data_source,
loaded_rows,
loaded_bytes
FROM sys_load_history
WHERE query_id IN (6389,490791,441663,74374,72297)
ORDER BY query_id,
data_source DESC;
샘플 출력은 다음과 같습니다.
query_id | table_name | data_source | loaded_rows | loaded_bytes
----------+------------------+-----------------------------------------------------------------------+-------------+---------------
6389 | store_returns | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store_returns/ | 287999764 | 1196240296158
72297 | web_site | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_site/ | 54 | 43808
74374 | ship_mode | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/ship_mode/ | 20 | 1320
441663 | income_band | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/income_band/ | 20 | 2152
490791 | customer_address | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/customer_address/ | 6000000 | 722924305
다음 쿼리는 copy 명령의 로드된 행, 바이트 수, 테이블 및 데이터 소스를 보여줍니다.
SELECT query_id,
table_name,
data_source,
loaded_rows,
loaded_bytes
FROM sys_load_history
ORDER BY query_id DESC
LIMIT 10;
샘플 출력은 다음과 같습니다.
query_id | table_name | data_source | loaded_rows | loaded_bytes
----------+------------------------+-----------------------------------------------------------------------------+-------------+-----------------
491058 | web_site | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_site/ | 54 | 43808
490947 | web_sales | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_sales/ | 720000376 | 22971988122819
490923 | web_returns | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_returns/ | 71997522 | 96597496325
490918 | web_page | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_page/ | 3000 | 1320
490907 | warehouse | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/warehouse/ | 20 | 1320
490902 | time_dim | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/time_dim/ | 86400 | 1320
490876 | store_sales | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store_sales/ | 2879987999 | 151666241887933
490870 | store_returns | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store_returns/ | 287999764 | 1196405607941
490865 | store | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store/ | 1002 | 365507
다음 쿼리는 copy 명령의 일별 로드된 행 및 바이트 수를 보여줍니다.
SELECT date_trunc('day',start_time) AS exec_day,
SUM(loaded_rows) AS loaded_rows,
SUM(loaded_bytes) AS loaded_bytes
FROM sys_load_history
GROUP BY exec_day
ORDER BY exec_day DESC;
샘플 출력은 다음과 같습니다.
exec_day | loaded_rows | loaded_bytes
---------------------+-------------+------------------
2022-01-20 00:00:00 | 6347386005 | 258329473070606
2022-01-19 00:00:00 | 19042158015 | 775198502204572
2022-01-18 00:00:00 | 38084316030 | 1550294469446883
2022-01-17 00:00:00 | 25389544020 | 1033271084791724
2022-01-16 00:00:00 | 19042158015 | 775222736252792
2022-01-15 00:00:00 | 19834245387 | 798122849155598
2022-01-14 00:00:00 | 75376544688 | 3077040926571384