forked from phamdinhkhanh/SQLCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestIndex.sql
80 lines (77 loc) · 1.66 KB
/
TestIndex.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
--Hieu nang cua create INDEX
--Khong su dung INDEX
DECLARE @TEST_PLAYER TABLE (ID int, MOST_PLAYER_ID int)
DECLARE @Start int
DECLARE @End int
DECLARE @i datetime
DECLARE @e datetime
SET @Start = 1
SET @End = 10000
WHILE (@Start < @End)
BEGIN
INSERT INTO @TEST_PLAYER
SELECT @Start, @Start + 1000
SET @Start = @Start + 1
END
SET @i = GETDATE()
SELECT * FROM @TEST_PLAYER
SET @e = GETDATE()
SELECT DATEDIFF(MILLISECOND,@i,@e)
--253
--su dung index
DECLARE @TEST_PLAYER TABLE(ID int INDEX Ix CLUSTERED, MOST_PLAYER_ID int)
DECLARE @Start int
DECLARE @End int
DECLARE @i datetime
DECLARE @e datetime
SET @Start = 1
SET @End = 10000
WHILE (@Start < @End)
BEGIN
INSERT INTO @TEST_PLAYER
SELECT @Start, @Start + 1000
SET @Start = @Start + 1
END
SET @i = GETDATE()
SELECT * FROM @TEST_PLAYER
SET @e = GETDATE()
SELECT DATEDIFF(MILLISECOND,@i,@e)
--253
DROP TABLE ##TEST_PLAYER
CREATE TABLE ##TEST_PLAYER(ID int INDEX Ix NONCLUSTERED, MOST_PLAYER_ID int)
DECLARE @Start int
DECLARE @End int
DECLARE @i datetime
DECLARE @e datetime
SET @Start = 1
SET @End = 100000
WHILE (@Start < @End)
BEGIN
INSERT INTO ##TEST_PLAYER
SELECT @Start, @Start + 1000
SET @Start = @Start + 1
END
SET @i = GETDATE()
SELECT * FROM ##TEST_PLAYER
SET @e = GETDATE()
SELECT DATEDIFF(MILLISECOND,@i,@e)
--1893
DROP TABLE ##TEST_PLAYER
CREATE TABLE ##TEST_PLAYER(ID int,MOST_PLAYER_ID int)
DECLARE @Start int
DECLARE @End int
DECLARE @i datetime
DECLARE @e datetime
SET @Start = 1
SET @End = 100000
WHILE (@Start < @End)
BEGIN
INSERT INTO ##TEST_PLAYER
SELECT @Start, @Start + 1000
SET @Start = @Start + 1
END
SET @i = GETDATE()
SELECT * FROM ##TEST_PLAYER
SET @e = GETDATE()
SELECT DATEDIFF(MILLISECOND,@i,@e)
--1916