-
Notifications
You must be signed in to change notification settings - Fork 0
/
time_query2.py
75 lines (68 loc) · 2.22 KB
/
time_query2.py
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
import sqlite3
from timeit import default_timer as timer
#32 SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth=? --- 20db
print("DB 20")
conn=sqlite3.connect("r20_noindex.db")
cursor=conn.cursor()
start1=timer()
cursor.execute('''SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth="10"''')
end1=timer()
data1=cursor.fetchall()
conn.close()
print(data1)
print("Time without index: ", end1-start1)
print("--------------------------------------------------")
conn=sqlite3.connect("r20_index.db")
cursor=conn.cursor()
start2=timer()
cursor.execute('''SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth="10"''')
end2=timer()
data2=cursor.fetchall()
conn.close()
print(data2)
print("Time with index: ", end2-start2)
print("--------------------------------------------------")
#32 SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth=? --- 20db --- 1000db
print("DB 1000")
conn=sqlite3.connect("r1000_noindex.db")
cursor=conn.cursor()
start3=timer()
cursor.execute('''SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth="30"''')
end3=timer()
data3=cursor.fetchall()
conn.close()
print(data3)
print("Time without index: ", end3-start3)
print("--------------------------------------------------")
conn=sqlite3.connect("r1000_index.db")
cursor=conn.cursor()
start4=timer()
cursor.execute('''SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth="30"''')
end4=timer()
data4=cursor.fetchall()
conn.close()
print(data4)
print("Time with index: ", end4-start4)
print("--------------------------------------------------")
#32 SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth=? --- 20db --- 5000db
print("DB 5000")
conn=sqlite3.connect("r5000_noindex.db")
cursor=conn.cursor()
start5=timer()
cursor.execute('''SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth="4787"''')
end5=timer()
data5=cursor.fetchall()
conn.close()
print(data5)
print("Time without index: ", end5-start5)
print("--------------------------------------------------")
conn=sqlite3.connect("r5000_index.db")
cursor=conn.cursor()
start6=timer()
cursor.execute('''SELECT ID_Krathshs FROM KANEI WHERE ID_Xrhsth="4787"''')
end6=timer()
data6=cursor.fetchall()
conn.close()
print(data6)
print("Time with index: ", end6-start6)
print("--------------------------------------------------")