Question: How do I create and prioritize query queues in my Amazon Redshift cluster?

I want to create and prioritize certain query queues in Amazon Redshift.

Short descriptionIn Amazon Redshift, you can create extract transform load (ETL) queries, and then separate them into different queues according to priority. Queries can be prioritized according to user group, query group, and query assignment rules.To prioritize your queries, use Amazon Redshift workload management (WLM). Amazon Redshift supports the following WLM configurations:Automatic WLM: When you enable automatic WLM, your query concurrency and memory allocation are managed by Amazon Redshift. Amazon Redshift determines the amount of resources that queries need, and adjusts the amount accordingly. Unlike manual WLM, automatic WLM allows you to set a query priority value to indicate the relative priority of workloads. For both automatic and manual WLM, you can create separate query queues.Manual WLM: Manual WLM is used to manage multiple WLM queues in Amazon Redshift. With manual WLM, you must specify values for WLM query concurrency slots and memory allocation properties. For both automatic and manual WLM, you can create separate query queues. For manual WLM, the default concurrency value is five queries and memory allocation is divided equally. Use manual WLM if you want to manage your own workload or manually assign resources to queries.To prioritize your queries, choose the WLM configuration that best fits your use case.

ResolutionAutomatic WLMWhen you enable automatic WLM, Amazon Redshift automatically determines how resources are allocated to each query. Concurrency is adjusted according to your workload.Note: It's a best practice to test automatic WLM on existing queries or workloads before moving the configuration to production.To prioritize your workload in Amazon Redshift using automatic WLM, perform the following steps:Sign in to the AWS Management Console.Open the Amazon Redshift console.From the navigation menu, choose CONFIG.Choose Workload management.Choose the parameter group that you want to modify.Choose the Workload management tab to view the current WLM configuration.(Optional) If your WLM parameter group is set to Automatic WLM mode, then no updates are required.(Optional) If your WLM parameter group is set to Manual WLM mode, modify the WLM configuration for your parameter group. Choose Edit workload queues to edit the WLM configuration. Then, choose Switch WLM mode to switch to Automatic WLM.Choose Add queue to add additional workload queues. You can create separate queues (with a maximum of eight queues) for each workload, associating queues with user groups or query groups.Choose Save.Assign queries to queues.Configure the priority status for your queue. By default, each queue is assigned a "Normal" priority status.Note: Superusers can apply a "Critical" priority status (the highest priority level) to a query. If a workload is marked as "Critical" priority, only one of its queries can be run at each time.(Optional) Create a WLM query monitoring rule to define performance boundaries (such as time limits or concurrency levels) for queries and queues. For example, you can set your query monitoring rule to change a query's priority status if a running query exceeds 40 seconds.Manual WLMWhen you enable manual WLM, each queue is allocated a portion of the cluster's available memory. A queue's memory is divided equally amongst the queue's query slots. If you're managing multiple WLM queues, you can configure workload management (WLM) queues to improve query processing.To prioritize your workload in Amazon Redshift using manual WLM, perform the following steps:Sign in to the AWS Management Console.Open the Amazon Redshift console.From the navigation menu, choose CONFIG.Choose Workload management.Choose the parameter group that you want to modify.Choose the Workload management tab to view the current WLM configuration.(Optional) If your WLM parameter group is set to Manual WLM mode, then no updates are required.(Optional) If your WLM parameter group is set to Automatic WLM mode, modify the WLM configuration for your parameter group. Choose Edit workload queues to edit the WLM configuration. Then, choose Switch WLM mode to switch to Manual WLM.Choose Add queue to add additional workload queues. You can create separate queues (with a maximum of eight queues) for each workload, associating queues with user groups or query groups.Choose Save.Create and define a query assignment rule.Note: Queries are assigned according to user or query group. Queries that aren't assigned run in the default queue.Use WLM dynamic memory allocation to configure the amount of memory allocated to each queue. WLM dynamic memory configuration helps you prioritize your workload according to memory usage.(Optional) Create and define a query monitoring rule to manage queries that reach metric boundaries. For example, you can use a query monitoring rule to hop or cancel a long-running query.

Related informationWLM queue assignment rulesWLM system tables and viewsSTV_WLM_QUERY_QUEUE_STATESTV_WLM_QUERY_STATESTV_WLM_SERVICE_CLASS_CONFIG