我正在考虑在WLM(工作负载管理)中为并发设置为1的真空查询设置一个单独的队列。 我选择并发1是因为在任何给定时刻只能运行一个真空查询。我试着想一想这个实现中是否会有任何问题。
当我运行以下查询来检查真空查询占用多少个插槽时,很明显,任何多级真空查询在任何给定的时间点只占用一个插槽。
SELECT wlm.query, wlm.slot_count, trim(q.text), queue_start_time, queue_end_time, total_queue_time
FROM stl_wlm_query wlm, stl_querytext q
WHERE wlm.query = q.query
AND text like '%Vacuum my_awesome_table%'
ORDER BY queue_start_time DESC;
query | slot_count | btrim | queue_start_time | queue_end_time
---------+------------+-------------------------------------------------------------------------+----------------------------+-----------------------------
1013242 | 1 | Vacuum my_awesome_table integrity check after vacuum execution | 2018-04-27 16:46:47.90601 | 2018-04-27 16:46:47.90601
1013237 | 1 | Vacuum my_awesome_table merge (increment: 2 remaining rows: 77234725) | 2018-04-27 16:46:40.785284 | 2018-04-27 16:46:40.785284
1013235 | 1 | Vacuum my_awesome_table merge (increment: 1) | 2018-04-27 16:46:29.789227 | 2018-04-27 16:46:29.789227
1013232 | 1 | Vacuum my_awesome_table sort (partition: 35 remaining rows: 331972) | 2018-04-27 16:46:16.978124 | 2018-04-27 16:46:16.978124
1013231 | 1 | Vacuum my_awesome_table sort (partition: 34 remaining rows: 1458914) | 2018-04-27 16:46:15.059653 | 2018-04-27 16:46:15.059653
1013229 | 1 | Vacuum my_awesome_table sort (partition: 33 remaining rows: 2586321) | 2018-04-27 16:46:13.641356 | 2018-04-27 16:46:13.641356
1013228 | 1 | Vacuum my_awesome_table sort (partition: 32 remaining rows: 3713038) | 2018-04-27 16:46:12.233741 | 2018-04-27 16:46:12.233741
1013227 | 1 | Vacuum my_awesome_table sort (partition: 31 remaining rows: 4839275) | 2018-04-27 16:46:10.838661 | 2018-04-27 16:46:10.838661
1013226 | 1 | Vacuum my_awesome_table sort (partition: 30 remaining rows: 5965341) | 2018-04-27 16:46:09.421457 | 2018-04-27 16:46:09.421457
1013225 | 1 | Vacuum my_awesome_table sort (partition: 29 remaining rows: 7090572) | 2018-04-27 16:46:07.93862 | 2018-04-27 16:46:07.93862
1013224 | 1 | Vacuum my_awesome_table sort (partition: 28 remaining rows: 8215908) | 2018-04-27 16:46:06.441227 | 2018-04-27 16:46:06.441227
1013223 | 1 | Vacuum my_awesome_table sort (partition: 27 remaining rows: 9341191) | 2018-04-27 16:46:05.009684 | 2018-04-27 16:46:05.009684
1013222 | 1 | Vacuum my_awesome_table sort (partition: 26 remaining rows: 10467621) | 2018-04-27 16:46:03.54458 | 2018-04-27 16:46:03.54458
1013221 | 1 | Vacuum my_awesome_table sort (partition: 25 remaining rows: 11594203) | 2018-04-27 16:46:01.998305 | 2018-04-27 16:46:01.998305
1013218 | 1 | Vacuum my_awesome_table sort (partition: 24 remaining rows: 12720513) | 2018-04-27 16:46:00.528971 | 2018-04-27 16:46:00.528971
1013217 | 1 | Vacuum my_awesome_table sort (partition: 23 remaining rows: 13844984) | 2018-04-27 16:45:59.071698 | 2018-04-27 16:45:59.071698
1013216 | 1 | Vacuum my_awesome_table sort (partition: 22 remaining rows: 14970941) | 2018-04-27 16:45:57.596597 | 2018-04-27 16:45:57.596597
1013215 | 1 | Vacuum my_awesome_table sort (partition: 21 remaining rows: 16097323) | 2018-04-27 16:45:56.253103 | 2018-04-27 16:45:56.253103
1013214 | 1 | Vacuum my_awesome_table sort (partition: 20 remaining rows: 17223270) | 2018-04-27 16:45:54.634498 | 2018-04-27 16:45:54.634498
1013213 | 1 | Vacuum my_awesome_table sort (partition: 19 remaining rows: 18351994) | 2018-04-27 16:45:53.265236 | 2018-04-27 16:45:53.265236
1013212 | 1 | Vacuum my_awesome_table sort (partition: 18 remaining rows: 19477834) | 2018-04-27 16:45:51.741294 | 2018-04-27 16:45:51.741294
1013211 | 1 | Vacuum my_awesome_table sort (partition: 17 remaining rows: 20605101) | 2018-04-27 16:45:50.338666 | 2018-04-27 16:45:50.338666
1013210 | 1 | Vacuum my_awesome_table sort (partition: 16 remaining rows: 21730370) | 2018-04-27 16:45:48.698214 | 2018-04-27 16:45:48.698214
1013209 | 1 | Vacuum my_awesome_table sort (partition: 15 remaining rows: 22856152) | 2018-04-27 16:45:46.27666 | 2018-04-27 16:45:46.27666
1013208 | 1 | Vacuum my_awesome_table sort (partition: 14 remaining rows: 23981990) | 2018-04-27 16:45:43.603719 | 2018-04-27 16:45:43.603719
1013206 | 1 | Vacuum my_awesome_table sort (partition: 13 remaining rows: 25107349) | 2018-04-27 16:45:40.848632 | 2018-04-27 16:45:40.848632
1013205 | 1 | Vacuum my_awesome_table sort (partition: 12 remaining rows: 26233207) | 2018-04-27 16:45:38.097134 | 2018-04-27 16:45:38.097134
1013204 | 1 | Vacuum my_awesome_table sort (partition: 11 remaining rows: 27359056) | 2018-04-27 16:45:35.316781 | 2018-04-27 16:45:35.316781
1013203 | 1 | Vacuum my_awesome_table sort (partition: 10 remaining rows: 28486363) | 2018-04-27 16:45:33.815825 | 2018-04-27 16:45:33.815825
1013202 | 1 | Vacuum my_awesome_table sort (partition: 9 remaining rows: 29612051) | 2018-04-27 16:45:32.262505 | 2018-04-27 16:45:32.262505
1013201 | 1 | Vacuum my_awesome_table sort (partition: 8 remaining rows: 30738238) | 2018-04-27 16:45:30.867315 | 2018-04-27 16:45:30.867315
1013200 | 1 | Vacuum my_awesome_table sort (partition: 7 remaining rows: 31864515) | 2018-04-27 16:45:29.476297 | 2018-04-27 16:45:29.476297
1013197 | 1 | Vacuum my_awesome_table sort (partition: 6 remaining rows: 32989591) | 2018-04-27 16:45:28.023365 | 2018-04-27 16:45:28.023365
1013196 | 1 | Vacuum my_awesome_table sort (partition: 5 remaining rows: 34115286) | 2018-04-27 16:45:26.607642 | 2018-04-27 16:45:26.607642
1013195 | 1 | Vacuum my_awesome_table sort (partition: 4 remaining rows: 35241021) | 2018-04-27 16:45:25.179251 | 2018-04-27 16:45:25.179251
1013194 | 1 | Vacuum my_awesome_table sort (partition: 3 remaining rows: 36367702) | 2018-04-27 16:45:23.167024 | 2018-04-27 16:45:23.167024
1013193 | 1 | Vacuum my_awesome_table sort (partition: 2 remaining rows: 37493086) | 2018-04-27 16:45:21.550219 | 2018-04-27 16:45:21.550219
1013192 | 1 | Vacuum my_awesome_table sort (partition: 1) | 2018-04-27 16:45:13.472849 | 2018-04-27 16:45:13.472849
1013188 | 1 | Vacuum my_awesome_table integrity check before vacuum execution | 2018-04-27 16:45:13.083657 | 2018-04-27 16:45:13.083657
1008690 | 1 | Vacuum my_awesome_table integrity check after vacuum execution | 2018-04-27 09:00:23.795686 | 2018-04-27 09:00:23.795686
1008686 | 1 | Vacuum my_awesome_table merge (increment: 2 remaining rows: 115824559) | 2018-04-27 09:00:15.527474 | 2018-04-27 09:00:15.527474
1008680 | 1 | Vacuum my_awesome_table merge (increment: 1) | 2018-04-27 09:00:00.946362 | 2018-04-27 09:00:00.946362
答案 0 :(得分:1)
使用多个队列的想法是阻止一组查询干扰另一组查询。将您的VACUUM放在一个单独的队列中意味着您的其他查询不会受到长期运行的VACUUM的影响。
VACUUM的并发性为1。
更重要的是你给它的内存量 - 越多越好,但是当VACUUM 不运行时你也不想浪费那些内存。
因此,如果您只为当天的部分运行VACUUM,则会在剩余时间内浪费队列。这可能不适合您的情况。