STL_LOAD_COMMITS - Amazon Redshift

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

STL_LOAD_COMMITS

傳回資訊以追蹤資料載入或對其進行故障診斷。

此檢視會在每一個資料檔案載入至資料庫資料表時記錄其進度。

所有使用者都可看見 STL_LOAD_COMMITS。超級使用者可以看見所有資料列;一般使用者只能看見自己的資料。如需詳細資訊,請參閱 系統資料表和檢視中資料的可見性

注意

STL_LOAD_COMMITS 僅包含在主叢集上執行的查詢。但不包含在並行擴縮叢集上執行的查詢。若要存取在主要和並行擴縮叢集上執行的查詢,建議您使用 SYS 監視檢視 SYS_LOAD_DETAIL。SYS 監視檢視中的資料會格式化為更易於使用和理解。

資料表欄

欄名稱 資料類型 描述
userid integer 產生項目的使用者之 ID。
query integer 查詢 ID。查詢欄可用於加入其他系統表格與檢視。
分割 integer 針對此項目載入的配量。
name character(256) 系統定義的值。
filename character(256) 正在追蹤之檔案的名稱。
byte_offset integer 此資訊僅供內部使用。
lines_scanned integer 從載入檔案掃描的行數。此數目可能不符合實際載入的資料列數目。例如,根據 COPY 命令中的 MAXERROR 選項,載入可能掃描但容忍一些錯誤記錄。
錯誤 integer 此資訊僅供內部使用。
curtime timestamp 上次更新此項目的時間。
status integer 此資訊僅供內部使用。
file_format character(16) 載入檔案的格式。可能的值如下:
  • Avro

  • JSON

  • ORC

  • Parquet

  • 文字

is_partial integer 如果值為 true (1),則表示輸入檔在 COPY 操作期間被分割為多個範圍。如果此值為 false (0),則輸入檔案不會分割。
start_offset bigint 如果輸入檔案在 COPY 操作期間被分割,則該值指示分割的偏移值 (以位元組為單位)。每個檔案分割都記錄為具有對應 start_offset 值的單獨記錄。如果檔案未分割,則此值為 0。
copy_job_id bigint 複製任務識別碼。0 表示沒有任務識別碼。

範例查詢

下列範例傳回上次 COPY 操作的詳細資訊。

select query, trim(filename) as file, curtime as updated from stl_load_commits where query = pg_last_copy_id(); query | file | updated -------+----------------------------------+---------------------------- 28554 | s3://dw-tickit/category_pipe.txt | 2013-11-01 17:14:52.648486 (1 row)

下列查詢包含 TICKIT 資料庫中全新載入之資料表的項目:

select query, trim(filename), curtime from stl_load_commits where filename like '%tickit%' order by query;
query | btrim | curtime -------+---------------------------+---------------------------- 22475 | tickit/allusers_pipe.txt | 2013-02-08 20:58:23.274186 22478 | tickit/venue_pipe.txt | 2013-02-08 20:58:25.070604 22480 | tickit/category_pipe.txt | 2013-02-08 20:58:27.333472 22482 | tickit/date2008_pipe.txt | 2013-02-08 20:58:28.608305 22485 | tickit/allevents_pipe.txt | 2013-02-08 20:58:29.99489 22487 | tickit/listings_pipe.txt | 2013-02-08 20:58:37.632939 22593 | tickit/allusers_pipe.txt | 2013-02-08 21:04:08.400491 22596 | tickit/venue_pipe.txt | 2013-02-08 21:04:10.056055 22598 | tickit/category_pipe.txt | 2013-02-08 21:04:11.465049 22600 | tickit/date2008_pipe.txt | 2013-02-08 21:04:12.461502 22603 | tickit/allevents_pipe.txt | 2013-02-08 21:04:14.785124 22605 | tickit/listings_pipe.txt | 2013-02-08 21:04:20.170594 (12 rows)

事實上,記錄寫入至此系統檢視的日誌檔案,並不表示已成功遞交載入,做為其包含交易的一部分。若要驗證載入遞交,請查詢 STL_UTILITYTEXT 檢視,並尋找與 COPY 交易相對應的 COMMIT 記錄。例如,此查詢會針對 STL_UTILITYTEXT 根據子查詢聯結 STL_LOAD_COMMITS 和 STL_QUERY:

select l.query,rtrim(l.filename),q.xid from stl_load_commits l, stl_query q where l.query=q.query and exists (select xid from stl_utilitytext where xid=q.xid and rtrim("text")='COMMIT'); query | rtrim | xid -------+---------------------------+------- 22600 | tickit/date2008_pipe.txt | 68311 22480 | tickit/category_pipe.txt | 68066 7508 | allusers_pipe.txt | 23365 7552 | category_pipe.txt | 23415 7576 | allevents_pipe.txt | 23429 7516 | venue_pipe.txt | 23390 7604 | listings_pipe.txt | 23445 22596 | tickit/venue_pipe.txt | 68309 22605 | tickit/listings_pipe.txt | 68316 22593 | tickit/allusers_pipe.txt | 68305 22485 | tickit/allevents_pipe.txt | 68071 7561 | allevents_pipe.txt | 23429 7541 | category_pipe.txt | 23415 7558 | date2008_pipe.txt | 23428 22478 | tickit/venue_pipe.txt | 68065 526 | date2008_pipe.txt | 2572 7466 | allusers_pipe.txt | 23365 22482 | tickit/date2008_pipe.txt | 68067 22598 | tickit/category_pipe.txt | 68310 22603 | tickit/allevents_pipe.txt | 68315 22475 | tickit/allusers_pipe.txt | 68061 547 | date2008_pipe.txt | 2572 22487 | tickit/listings_pipe.txt | 68072 7531 | venue_pipe.txt | 23390 7583 | listings_pipe.txt | 23445 (25 rows)

以下範例反白顯示 is_partial 和 start_offset 欄值。

-- Single large file copy without scan range SELECT count(*) FROM stl_load_commits WHERE query = pg_last_copy_id(); 1 -- Single large uncompressed, delimited file copy with scan range SELECT count(*) FROM stl_load_commits WHERE query = pg_last_copy_id(); 16 -- Scan range offset logging in the file at 64MB boundary. SELECT start_offset FROM stl_load_commits WHERE query = pg_last_copy_id() ORDER BY start_offset; 0 67108864 134217728 201326592 268435456 335544320 402653184 469762048 536870912 603979776 671088640 738197504 805306368 872415232 939524096 1006632960