

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

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

# SYS\_LOAD\_HISTORY
<a name="SYS_LOAD_HISTORY"></a>

使用 SYS\_LOAD\_HISTORY 來檢視 COPY 命令的詳細資訊。每一列代表一個 COPY 命令，其中包含某些欄位的累計統計資料。它包含正在執行和已完成的 COPY 命令。

所有使用者都可看見 SYS\_LOAD\_HISTORY。超級使用者可以看見所有資料列；一般使用者只能看見自己的資料。如需詳細資訊，請參閱[系統資料表和檢視中資料的可見性](cm_chap_system-tables.md#c_visibility-of-data)。

## 資料表欄
<a name="SYS_LOAD_HISTORY-table-columns"></a>


| 欄名稱  | 資料類型  | Description  | 
| --- | --- | --- | 
| user\_id | integer | 提交副本之使用者的識別碼。 | 
| query\_id | bigint | 副本的查詢識別碼。 | 
| transaction\_id | bigint | 交易識別碼。 | 
| session\_id | integer | 執行副本之程序的處理程序識別碼。 | 
| database\_name | text | 發出操作時，要將使用者連接至其中的資料庫名稱。 | 
| status | text | 副本的狀態。有效值為 running、completed、aborted。 | 
| table\_name | text | 複製到的資料表的名稱。 | 
| start\_time | timestamp | 複製開始的時間。 | 
| end\_time | timestamp | 複製完成的時間。 | 
| duration | bigint | COPY 命令花費的時間 (微秒)。 | 
| data\_source | text | 要複製檔案輸入的 Amazon S3 位置。 | 
| file\_format | text | 來源檔案格式。格式包括 csv、txt、json、avro、orc 或 parquet。 | 
| loaded\_rows | bigint | 複製到資料表的列數。 | 
| loaded\_bytes | bigint | 複製到資料表的位元組數。 | 
| source\_file\_count | integer | 來源檔案中的檔案數。 | 
| source\_file\_bytes | bigint | 來源檔案中的位元組數。 | 
| file\_count\_scanned | integer | 從 Amazon S3 掃描的檔案數。 | 
| file\_bytes\_scanned | bigint | 從 Amazon S3 中的檔案掃描的位元組數。 | 
| error\_count | bigint | 錯誤計數。 | 
| copy\_job\_id  | bigint  | 複製任務識別碼。0 表示沒有任務識別碼。 | 

## 範例查詢
<a name="SYS_LOAD_HISTORY-sample-queries"></a>

下列查詢顯示特定複製命令的載入列、位元組、資料表和資料來源。

```
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
```

下列查詢顯示複製命令的載入列、位元組、資料表和資料來源。

```
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
```

 下列查詢顯示複製命令的每日載入列和位元組。

```
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
```