

 Amazon Redshift non supporterà più la creazione di nuovi Python UDFs a partire dalla Patch 198. Python esistente UDFs continuerà a funzionare fino al 30 giugno 2026. Per ulteriori informazioni, consulta il [post del blog](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/). 

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# SYS\$1QUERY\$1DETAIL
<a name="SYS_QUERY_DETAIL"></a>

Utilizza SYS\$1QUERY\$1DETAIL per visualizzare i dettagli delle query a vari livelli di metrica, con ogni riga che rappresenta i dettagli di una particolare query WLM a un determinato livello di metrica. Questa vista contiene molti tipi di query come DDL, DML e comandi di utilità (ad esempio, copia e scarica). Alcune colonne potrebbero non essere rilevanti a seconda del tipo di query. Ad esempio, external\$1scanned\$1bytes non è rilevante per le tabelle interne.

SYS\$1QUERY\$1DETAIL è visibile a tutti gli utenti. Gli utenti con privilegi avanzati visualizzano tutte le righe; gli utenti regolari visualizzano solo i propri dati. Per ulteriori informazioni, consulta [Visibilità dei dati nelle tabelle e nelle viste di sistema](cm_chap_system-tables.md#c_visibility-of-data).

**Nota**  
Per verificare se il commit di una transazione contenente la query eseguita è riuscito, devi effettuare il join tra le tabelle di sistema e la tabella `sys_transaction_history`. Esempio:  

```
SELECT 
    th.transaction_id,
    qd.query_id,
    th.status AS transaction_status
FROM 
    sys_query_detail qd
LEFT JOIN sys_query_history qh ON qd.query_id = qh.query_id
LEFT JOIN sys_transaction_history th on qh.transaction_id = th.transaction_id;
```

## Colonne di tabella
<a name="SYS_QUERY_DETAIL-table-columns"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/redshift/latest/dg/SYS_QUERY_DETAIL.html)

## Note per l’utilizzo
<a name="SYS_QUERY_DETAIL-usage-notes"></a>

SYS\$1QUERY\$1DETAIL può contenere metriche a livello di fase, flusso, segmento e query secondaria. Oltre a fare riferimento alla colonna metrics\$1level, puoi determinare il livello di metriche mostrato in una data riga facendo riferimento ai campi step\$1id, segment\$1id e stream\$1id in base alla tabella seguente.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/redshift/latest/dg/SYS_QUERY_DETAIL.html)

## Query di esempio
<a name="SYS_QUERY_DETAIL-sample-queries"></a>

L'esempio seguente restituisce l'output di SYS\$1QUERY\$1DETAIL.

La seguente query mostra i dettagli dei metadati della query a livello di fase, inclusi nome fase, input\$1bytes, output\$1bytes, input\$1rows, output\$1rows.

```
SELECT query_id,
       child_query_sequence,
       stream_id,
       segment_id,
       step_id,
       trim(step_name) AS step_name,
       duration,
       input_bytes,
       output_bytes,
       input_rows,
       output_rows
FROM sys_query_detail
WHERE query_id IN (193929)
ORDER BY query_id,
         stream_id,
         segment_id,
         step_id DESC;
```

Output di esempio.

```
 query_id | child_query_sequence | stream_id | segment_id | step_id | step_name  |    duration     | input_bytes | output_bytes | input_rows | output_rows
----------+----------------------+-----------+------------+---------+------------+-----------------+-------------+--------------+------------+-------------
   193929 |                    2 |         0 |          0 |       3 | hash       |           37144 |           0 |      9350272 |          0 |      292196
   193929 |                    5 |         0 |          0 |       3 | hash       |            9492 |           0 |        23360 |          0 |        1460
   193929 |                    1 |         0 |          0 |       3 | hash       |           46809 |           0 |      9350272 |          0 |      292196
   193929 |                    4 |         0 |          0 |       2 | return     |            7685 |           0 |          896 |          0 |         112
   193929 |                    1 |         0 |          0 |       2 | project    |           46809 |           0 |            0 |          0 |      292196
   193929 |                    2 |         0 |          0 |       2 | project    |           37144 |           0 |            0 |          0 |      292196
   193929 |                    5 |         0 |          0 |       2 | project    |            9492 |           0 |            0 |          0 |        1460
   193929 |                    3 |         0 |          0 |       2 | return     |           11033 |           0 |        14336 |          0 |         112
   193929 |                    2 |         0 |          0 |       1 | project    |           37144 |           0 |            0 |          0 |      292196
   193929 |                    1 |         0 |          0 |       1 | project    |           46809 |           0 |            0 |          0 |      292196
   193929 |                    5 |         0 |          0 |       1 | project    |            9492 |           0 |            0 |          0 |        1460
   193929 |                    3 |         0 |          0 |       1 | aggregate  |           11033 |           0 |       201488 |          0 |          14
   193929 |                    4 |         0 |          0 |       1 | aggregate  |            7685 |           0 |        28784 |          0 |          14
   193929 |                    5 |         0 |          0 |       0 | scan       |            9492 |           0 |        23360 |     292196 |        1460
   193929 |                    4 |         0 |          0 |       0 | scan       |            7685 |           0 |         1344 |        112 |         112
   193929 |                    2 |         0 |          0 |       0 | scan       |           37144 |           0 |      7304900 |     292196 |      292196
   193929 |                    3 |         0 |          0 |       0 | scan       |           11033 |           0 |        13440 |        112 |         112
   193929 |                    1 |         0 |          0 |       0 | scan       |           46809 |           0 |      7304900 |     292196 |      292196
   193929 |                    5 |         0 |          0 |      -1 |            |            9492 |       12288 |            0 |          0 |           0
   193929 |                    1 |         0 |          0 |      -1 |            |           46809 |       16384 |            0 |          0 |           0
   193929 |                    2 |         0 |          0 |      -1 |            |           37144 |       16384 |            0 |          0 |           0
   193929 |                    4 |         0 |          0 |      -1 |            |            7685 |       28672 |            0 |          0 |           0
   193929 |                    3 |         0 |          0 |      -1 |            |           11033 |      114688 |            0 |          0 |           0
```

Per visualizzare le tabelle del database nell'ordine dalla più utilizzata a quella meno utilizzata, utilizza l'esempio seguente. Sostituiscilo *sample\$1data\$1dev* con il tuo database. Tieni presente che questa query calcolerà le query a partire dalla creazione del cluster, ma i dati della vista di sistema non vengono salvati quando nel data warehouse manca spazio.

```
SELECT table_name, COUNT (DISTINCT query_id) 
FROM SYS_QUERY_DETAIL 
WHERE table_name LIKE 'sample_data_dev%'
GROUP BY table_name
ORDER BY COUNT(*) DESC;

+---------------------------------+-------+
|           table_name            | count |
+---------------------------------+-------+
| sample_data_dev.tickit.venue    |     4 |
| sample_data_dev.myunload1.venue |     3 |
| sample_data_dev.tickit.listing  |     1 |
| sample_data_dev.tickit.category |     1 |
| sample_data_dev.tickit.users    |     1 |
| sample_data_dev.tickit.date     |     1 |
| sample_data_dev.tickit.sales    |     1 |
| sample_data_dev.tickit.event    |     1 |
+---------------------------------+-------+
```

 Nell’esempio seguente mostra i vari livelli di metriche per una singola query WLM. 

```
SELECT query_id, child_query_sequence, stream_id, segment_id, step_id, step_name, start_time, end_time, metrics_level 
FROM sys_query_detail 
WHERE query_id = 1553 AND step_id = -1 
ORDER BY stream_id, segment_id, step_id;

 query_id | child_query_sequence | stream_id | segment_id | step_id | step_name |         start_time         |          end_time          | metrics_level 
----------+----------------------+-----------+------------+---------+-----------+----------------------------+----------------------------+---------------
     1553 |                    1 |        -1 |         -1 |      -1 |           | 2024-10-17 02:28:49.814721 | 2024-10-17 02:28:49.847838 | child query
     1553 |                    1 |         0 |         -1 |      -1 |           | 2024-10-17 02:28:49.814721 | 2024-10-17 02:28:49.835609 | stream
     1553 |                    1 |         0 |          0 |      -1 |           | 2024-10-17 02:28:49.824677 | 2024-10-17 02:28:49.830372 | segment
     1553 |                    1 |         1 |         -1 |      -1 |           | 2024-10-17 02:28:49.835624 | 2024-10-17 02:28:49.845773 | stream
     1553 |                    1 |         1 |          1 |      -1 |           | 2024-10-17 02:28:49.84088  | 2024-10-17 02:28:49.842388 | segment
     1553 |                    1 |         1 |          2 |      -1 |           | 2024-10-17 02:28:49.835926 | 2024-10-17 02:28:49.844396 | segment
     1553 |                    1 |         2 |         -1 |      -1 |           | 2024-10-17 02:28:49.846949 | 2024-10-17 02:28:49.847838 | stream
     1553 |                    1 |         2 |          3 |      -1 |           | 2024-10-17 02:28:49.847013 | 2024-10-17 02:28:49.847485 | segment
(8 rows)
```