Oracle - 需要查询以最大化CPU

问题描述 投票:1回答:1

需要很少的查询来在CPU上生成负载,并最终将其最大化为100%。执行时的查询应该能够产生高CPU使用率。

oracle resources cpu-usage
1个回答
1
投票

试试这个

declare 
    l_job_out integer;
    l_what dba_jobs.what%type;
    l_cpus_to_hog CONSTANT integer :=4;
    l_loop_count varchar2(10) := '500000000'; 
begin

/* 
** Create some jobs to load the CPU
*/
    for l_job in 1..l_cpus_to_hog loop 
        dbms_job.submit(
        job => l_job_out
        , what => 'declare a number := 1; begin for i in 1..'||l_loop_count||' loop a := ( a + i )/11; end loop; end;'
        );
        commit;   
        dbms_output.put_line( 'job - '|| l_job_out );
        select what into l_what 
        from dba_jobs 
        where job = l_job_out;
        dbms_output.put_line( 'what - '|| l_what );
    end loop;
end;
© www.soinside.com 2019 - 2024. All rights reserved.