列存储里,我在测试的时候确实看到了IO的大量减少。但是为什么运行的时间却大大的加长了。
另一个表里没有列存储的。为什么IO很多,而时间却很短?不太明白这个事情,请高手解答下这个疑问
------解决方案--------------------
很艰难才找到有点数据量的库来做测试:
第一个,没有索引在上面,查找出10万数据,原表22071383数据,下面是测试结果,接近3分钟
SET STATISTICS IO ON ;
SET STATISTICS TIME ON ;
SELECT DCPPaymentName FROM DCPPaymentTracking WHERE DCPPaymentName='DP0116'
SET STATISTICS TIME OFF;
SET STATISTICS IO OFF;
/*
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
(108318 row(s) affected)
Table 'DCPPaymentTracking'. Scan count 5, logical reads 388503, physical reads 3828, read-ahead reads 240576, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 3634 ms, elapsed time = 156454 ms.
*/
第二个:在需要查找的列上加了一个列存储索引,几乎秒杀:
所以可以说,列存储索引是有效的,你的例子比较复杂,我也没环境,不好测,我初步觉得是因为你没有用好列存储索引,如果你要找的数据就在列存储上面,那么应该是很快的。
SET STATISTICS IO ON ;
SET STATISTICS TIME ON ;
SELECT DCPPaymentName FROM DCPPaymentTracking WHERE DCPPaymentName='DP0116'
SET STATISTICS TIME OFF;
SET STATISTICS IO OFF;
/*
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 0 ms.
(108318 row(s) affected)
Table 'DCPPaymentTracking'. Scan count 4, logical reads 472, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 94 ms, elapsed time = 1246 ms.
*/