forked from sculite/sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gpu.sql
More file actions
108 lines (95 loc) · 2.94 KB
/
test_gpu.sql
File metadata and controls
108 lines (95 loc) · 2.94 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
-- GPU-Accelerated SQLite Test - 10 Million Rows
.print ========================================
.print SQLite GPU Acceleration Test
.print 10 Million Row Performance Test
.print ========================================
.print
-- Create test table
.print Creating test table...
DROP TABLE IF EXISTS gpu_test;
CREATE TABLE gpu_test (
id INTEGER PRIMARY KEY,
age INTEGER,
score INTEGER,
category INTEGER,
value INTEGER
);
-- Insert 10 million rows
.print Inserting 10,000,000 rows... (this will take a few minutes)
BEGIN TRANSACTION;
WITH RECURSIVE cnt(x) AS (
SELECT 1
UNION ALL
SELECT x+1 FROM cnt
LIMIT 10000000
)
INSERT INTO gpu_test (id, age, score, category, value)
SELECT
x,
20 + (x % 60),
(x * 17) % 100,
(x % 10),
(x * 13) % 10000
FROM cnt;
COMMIT;
.print Done!
.print
-- Verify
SELECT COUNT(*) AS total_rows FROM gpu_test;
.print
-- Test 1: Simple equality
.print ========================================
.print Test 1: Simple Equality WHERE
.print Query: SELECT COUNT(*) FROM gpu_test WHERE age = 30
.print ========================================
.timer ON
SELECT COUNT(*) AS matches FROM gpu_test WHERE age = 30;
.timer OFF
.print
-- Test 2: Range query
.print ========================================
.print Test 2: Greater Than WHERE
.print Query: SELECT COUNT(*) FROM gpu_test WHERE score > 50
.print ========================================
.timer ON
SELECT COUNT(*) AS matches FROM gpu_test WHERE score > 50;
.timer OFF
.print
-- Test 3: Multiple AND conditions
.print ========================================
.print Test 3: Multiple AND Conditions
.print Query: SELECT COUNT(*) FROM gpu_test WHERE age >= 25 AND score <= 75
.print ========================================
.timer ON
SELECT COUNT(*) AS matches FROM gpu_test WHERE age >= 25 AND score <= 75;
.timer OFF
.print
-- Test 4: Three-way AND
.print ========================================
.print Test 4: Three AND Conditions
.print Query: SELECT COUNT(*) FROM gpu_test WHERE age > 30 AND score < 80 AND category = 5
.print ========================================
.timer ON
SELECT COUNT(*) AS matches FROM gpu_test WHERE age > 30 AND score < 80 AND category = 5;
.timer OFF
.print
-- Test 5: Complex range
.print ========================================
.print Test 5: Complex Range
.print Query: SELECT COUNT(*) FROM gpu_test WHERE value >= 1000 AND value < 5000
.print ========================================
.timer ON
SELECT COUNT(*) AS matches FROM gpu_test WHERE value >= 1000 AND value < 5000;
.timer OFF
.print
-- Test 6: Return actual rows
.print ========================================
.print Test 6: Return Rows
.print Query: SELECT id, age, score FROM gpu_test WHERE age = 25 LIMIT 10
.print ========================================
SELECT id, age, score FROM gpu_test WHERE age = 25 LIMIT 10;
.print
.print ========================================
.print Test Complete!
.print Check stderr for GPU messages
.print ========================================