A simple way to make High CPU Utilization
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