Get the App
SLTechnology News&Howtos  ›  Database  › 

A simple way to make High CPU Utilization

Shulou Source: shulou.com Published: 2022-06-01 13:45:46 11月15日 Update

Today, someone in the group asked to create scenarios with high CPU occupancy for testing. As the saying goes, it is difficult to do good things, but it is not easy to do "bad" things. There are many ways to achieve this requirement, such as using some stress testing tools. The first thing that comes to mind is HASH JOIN. This connection consumes more CPU resources. Take two tables to HASH JOIN, preferably those with large fields, open a few more processes, and the CPU utilization rate will soar to 80-90%!

The following is to use a system view for HASH JOIN to achieve, simple and fast.

DECLARE @ I BIGINTWHILE (1x 1) BEGIN SELECT @ I = COUNT (*) FROM sys.all_objects AS a LEFT HASH JOIN sys.all_objects AS b ON b.name = a.nameEndtGo

Code-1: HASH JOIN

I only opened four session in SSMS and ran the above script's rendering at the same time. Please stop running the script manually after the test.

Figure-1: CPU usage shown by performance counters

Figure-2: CPU resource usage displayed by the Task Manager

Tags: Tests situations scripts resources runs usage methods manufacturing tasks stress at the same time scenarios fields tools performance manual effects rendering best testing tools Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MariaDB vpn Shulou Tech Info Linux