九亿计数据记录
导入数据前
d 盘的可用量为310G
-- 执行450000次每次2000条记录
CREATE PROCEDURE daemonDataGenerate
AS
declare @cnt INT
set @cnt = 450000
WHILE @cnt > 0
BEGIN
INSERT INTO BOHRSCSALES_MIN SELECT AMOUNT,TRANSACTIONTYPE,POSID,COUNT,
TRANSACTIONID,CASHIERID,BEGINTIME,ENDTIME,UNITPRICE,ITEMTYPE,TRANSACTIONDATE,
ITEMCODE,LEFT(GLOBALCODE,3) + CAST(RIGHT(GLOBALCODE,(datalength(GLOBALCODE)/2)-3)+@cnt AS char)
AS GLOBALCODE,FLAG_DT,Attr_1,Attr_2,PartySize FROM dbo.BOHRSCSALES_MIN_TEMP
set @cnt = (@cnt - 1)
END
print @cnt;
导入数据后
插入时间为3:31:28秒
d 盘的可用量为178G
占用132G
count(*)统计全部占用时间22:05秒
创建索引
CREATE INDEX idx_BOHRSCSALES_DAY_r1 ON BOHRSCSALES_DAY(GLOBALCODE,ITEMCODE,ITEMTYPE);
所用时间2.16.03
磁盘空间变化2.9MB
在索引列上count,所需时间14:56秒
select count(GLOBALCODE) from BOHRSCSALES_DAY;
在索引列上查询,所需时间00
select * from BOHRSCSALES_DAY where ITEMCODE='550124' AND GLOBALCODE='PSH914';