作为压力测试的一部分,我正在尝试确定是否存在一个SQL查询(特别是SQL Server查询),该查询将使所有CPU使用率最大达到100%或足够接近。
有人建议吗?
SELECT SUM(CONVERT(BIGINT, o1.object_id) + CONVERT(BIGINT, o2.object_id) + CONVERT(BIGINT, o3.object_id) + CONVERT(BIGINT, o4.object_id)) FROM sys.objects o1 CROSS JOIN sys.objects o2 CROSS JOIN sys.objects o3 CROSS JOIN sys.objects o4
这是一个并行版本:
USE master SELECT MyInt = CONVERT(BIGINT, o1.object_id) + CONVERT(BIGINT, o2.object_id) + CONVERT(BIGINT, o3.object_id) INTO #temp FROM sys.objects o1 JOIN sys.objects o2 ON o1.object_id < o2.object_id JOIN sys.objects o3 ON o1.object_id < o3.object_id SELECT SUM(CONVERT(BIGINT, o1.MyInt) + CONVERT(BIGINT, o2.MyInt)) FROM #temp o1 JOIN #temp o2 ON o1.MyInt < o2.MyInt
由于某种原因,我无法使优化器并行化第一个查询。因此,我只是实现一些巨大的表(约40万行)并循环连接它们。