Amazon Redshift の STL_QUERYのconcurrency_scaling_statusの仕様

RedshiftのシステムビューであるSTL_QUERY、実行された全SQLのメタデータを確認できる。

https://docs.aws.amazon.com/ja_jp/redshift/latest/dg/r_STL_QUERY.html

そこにconcurrency_scaling_statusという列があり、[同時実行スケーリング](https://docs.aws.amazon.com/ja_jp/redshift/latest/dg/concurrency-scaling.html)の対象になったかどうかのステータスが格納されている。

公式ドキュメントでは、concurrency_scaling_status=1の時に「同時実行スケーリングクラスターで実行された」、それ以外の時は「メインクラスターで実行された」ということになっている。

STL_QUERYには、0と1以外にも様々な値が入っている。
ここから、「同時実行スケーリング対象にならなかった理由」を探ることができそう。

ただ、値の詳細についてドキュメントには記載がない。
ネットで探していたら、非公式だがconcurrency_scaling_statusの詳細が分かるような資料が見つかった。

https://www.amazonredshiftresearchproject.org/system_table_explorer/index.html

上記サイトの左メニューに「pg_catalog.svl_query_concurrency_scaling_status」がある。
見づらいので整理して以下に記載する。

concurrency_scaling_status | 意味
-- | --
1 | Ran on a Concurrency Scaling cluster
0 | Ran on the main cluster
2 | Concurrency Scaling not enabled
4 | Concurrency Scaling ineligible query - System temporary table accessed
5 | Concurrency Scaling ineligible query - User temporary table accessed
6 | Concurrency Scaling ineligible query - System table accessed
3 | Concurrency Scaling ineligible query - Query is an Unsupported DML
7 | Concurrency Scaling ineligible query - No backup table accessed
8 | Concurrency Scaling ineligible query - Zindex table accessed
9 | Concurrency Scaling ineligible query - Query uses UDF
10 | Concurrency Scaling ineligible query - Catalog tables accessed
11 | Concurrency Scaling ineligible query - Dirty table accessed
12 | Concurrency Scaling ineligible query - Direct dispatched query
16 | Concurrency Scaling ineligible query - No tables accessed
17 | Concurrency Scaling ineligible query - Spectrum queries are disabled
18 | Concurrency Scaling ineligible query - Function not supported 
19 | Concurrency Scaling ineligible query - Instance type not supported 
20 | Concurrency Scaling ineligible query - Burst temporarily disabled 
21 | Concurrency Scaling ineligible query - Unload queries are disabled 
22 | Concurrency Scaling ineligible query - Unsupported unload type 
23 | Concurrency Scaling ineligible query - Non VPC clusters cannot burst 
24 | Concurrency Scaling ineligible query - VPCE not setup 
25 | Concurrency Scaling failed query - Inelegible to rerun on main cluster due to failure handling not enabled
26 | Concurrency Scaling failed query - Inelegible to rerun on main cluster due to concurrency scaling not auto
27 | Concurrency Scaling failed query - Inelegible to rerun on main cluster due to results already returning 
28 | Concurrency Scaling failed query - Inelegible to rerun on main cluster due to non retriable error 
29 | Concurrency Scaling failed query - Elegible to rerun on main cluster 
30 | Concurrency Scaling inelegible query - Cumulative time not met 
31 | Concurrency Scaling inelegible query - Paused query 
32 | Query assigned to non Concurrency Scaling queue 
33 | Concurrency Scaling ineligible query - Query has state on Main cluster 
34 | Concurrency Scaling ineligible query - Query is inelegible for bursting Volt CTAS 
35 | Concurrency Scaling ineligible query - Resource blacklisted 
36 | Concurrency Scaling ineligible query - Non-retryable VoltTT queries are blacklisted 
37 | Concurrency Scaling ineligible query - Query is retrying on Main cluster 
38 | Concurrency Scaling ineligible query - Cannot burst Volt-created CTAS using cursors 
39 | Concurrency Scaling usage limit reached 
40 | Concurrency Scaling ineligible query - Unsupported VoltTT Utility query 
41 | Concurrency Scaling ineligible query - Write query generating Volt TTs 
42 | Concurrency Scaling ineligible query - VoltTT query with invalid state 
43 | Concurrency Scaling ineligible query - Explain query generating Volt TTs 
44 | Concurrency Scaling ineligible query - Bursting Volt-generated queries is disabled 
45 | Concurrency Scaling ineligible query - Resource of VoltTT UNLOAD is blacklisted 
46 | Concurrency Scaling ineligible query - Multiple pre-Volt query trees 
48 | Concurrency Scaling ineligible query - Target table is DistAll/DistAutoAll 
49 | Concurrency Scaling ineligible query - Table that has diststyle changed in current txn accessed 
50 | Concurrency Scaling ineligible query - Cannot burst spectrum copy 
51 | Concurrency Scaling ineligible query - Dirty transaction tables accessed  
52 | Concurrency Scaling ineligible query - Table that has identity column as a target table 
53 | Concurrency Scaling ineligible query - Datasharing remote tables accessed
54 | Concurrency Scaling ineligible query - Target table with comp update
55 | Concurrency Scaling ineligible query - Nested tables accessed
56 | Concurrency Scaling ineligible query - Copy from EMR 
59 | Concurrency Scaling ineligible query - Table that has column encode changed in current txn accessed 
60 | Concurrency Scaling ineligible query - MV refresh disabled 
61 | Concurrency Scaling ineligible query - Too many concurrent writes 
62 | Concurrency Scaling ineligible query - Main cluster too big for writes 
63 | Concurrency Scaling ineligible query - Datasharing VoltTT 
64 | Concurrency Scaling ineligible query - Target table has super/geo column 
65 | Concurrency Scaling rejected query - Ineligible to queue on burst cluster, eligible to rerun on any cluster 
66 | Concurrency Scaling ineligible query - Datasharing with burst-write
67 | Concurrency Scaling ineligible query - CTAS with burst-write
68 | Concurrency Scaling ineligible query - COPY on tables with identity columns
70 | Concurrency Scaling ineligible query - Datasharing query with cursor