Redshift で WLM キューが溜まった状態から Concurrency scaling を有効化後に Scaling cluster でクエリが実行されるまでの時間を検証してみた。
環境セットアップ手順は以下参照。
Amazon Redshift に重いクエリを同時多重実行しながら性能情報を見る - ablog
シナリオ
SQL
- lineorder.sql
unload ('select (a.*) from public.lineorder a, public.lineorder b') to's3://redshift-unload-ab/lineorder/' iam_role 'arn:aws:iam::123456789012:role/redshift-spectrum-s3-fullaccess' allowoverwrite csv;
- lineorder_limit.sql
select * from public.lineorder limit 1000;
手順
- 30並列で UNLOAD を実行してキュー待ちクエリを発生させる(Scaling cluster で実行されないクエリ)。
$ nohup pgbench -r -c 30 -j 30 -n -t 100 -f lineorder.sql -U awsuser -h redshift-cluster-poc-central.********.ap-northeast-1.redshift.amazonaws.com -d dev -p 5439 &
- 30並列で CS で実行可能なクエリを実行して、CS を起動させる(Scaling cluster で実行されるクエリ)。
$ nohup pgbench -r -c 30 -j 30 -n -t 100 -f lineorder_limit.sql -U awsuser -h redshift-cluster-poc-central.********.ap-northeast-1.redshift.amazonaws.com -d dev -p 5439 &
- 上記を実行開始後に WLM 設定で Default Queue の Concurrency scaling を auto に設定する。

=# select service_class, name, concurrency_scaling, query_priority from STV_WLM_SERVICE_CLASS_CONFIG; service_class | name | concurrency_scaling | query_priority ---------------+------------------------------------------------------------------+----------------------+---------------------- 1 | Service class for system user (Health Check) | off | Normal 2 | Service class for system user (Metrics Collection) | off | Normal 3 | Service class for system user (CM Stats) | off | Normal 4 | Service class for system user (Operator) | off | Normal 5 | Service class for super user | off | Normal 14 | Short query queue | off | Normal 15 | Service class for vacuum/analyze | off | Normal 100 | main_queue | off | High 101 | dwh_tool_queue | off | Normal 102 | user_queue | off | Low 103 | admin_queue | off | Highest 104 | Default queue | auto | Normal (12 rows)
検証ポイント
- 最初から Concurrency scaling が有効な状態で同時多重でクエリを実行し、Scaling cluster でクエリが実行されることを確認する。
- 同じシナリオで同時多重でクエリを実行し、キュー待ちが溜まった状態で Concurrency scaling を有効化し、Scaling cluster でクエリが実行されることを確認する。
検証結果
最初から Concurrency scaling が有効な状態で同時多重でクエリを実行し、Scaling cluster でクエリが実行されることを確認する。

同じシナリオで同時多重でクエリを実行し、キュー待ちが溜まった状態で Concurrency scaling を有効化し、Scaling cluster でクエリが実行されることを確認する。
- 2025/10/22 14:16(JST) Concurrency scaling 有効化

- 2025/10/23 5:32(JST) Concurrency scaling 有効化
- Concurrency scaling 有効化前に実行していたクエリは 5:41 頃に Scaling cluster で捌ききれたため、5:43 に Scaling cluster で実行できるクエリを再度発行し、Concurrency scaling で実行されていることを確認。

=# select b.generic_query_hash, a.concurrency_scaling_status, count(b.generic_query_hash), min(a.querytxt), min(a.starttime), min(a.starttime) from stl_query a, sys_query_history b where b.generic_query_hash in ('n9fSC5vQokU=', 'oky5dmYqwxk=') and a.starttime > '2025-10-22 20:00' and a.xid = b.transaction_id group by b.generic_query_hash, concurrency_scaling_status order by b.generic_query_hash, concurrency_scaling_status; generic_query_hash | concurrency_scaling_status | count | min | min | min ------------------------------------------+----------------------------+-------+--------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+---------------------------- n9fSC5vQokU= | 0 | 11464 | select * from public.lineorder limit 1000; | 2025-10-22 20:28:14.374692 | 2025-10-22 20:28:14.374692 n9fSC5vQokU= | 1 | 6536 | select * from public.lineorder limit 1000; | 2025-10-22 20:40:29.696821 | 2025-10-22 20:40:29.696821 oky5dmYqwxk= | 26 | 20 | unload ('select (a.*) from public.lineorder a, public.lineorder b') to's3://redshift-unload-ab/lineorder/' iam_role '' allowoverwrite csv; | 2025-10-22 20:12:32.789617 | 2025-10-22 20:12:32.789617 oky5dmYqwxk= | 65 | 58 | unload ('select (a.*) from public.lineorder a, public.lineorder b') to's3://redshift-unload-ab/lineorder/' iam_role '' allowoverwrite csv; | 2025-10-22 20:09:37.218847 | 2025-10-22 20:09:37.218847 (4 rows)