-
-
Notifications
You must be signed in to change notification settings - Fork 817
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
CREATE TEMP TABLE Bits (Bit INTEGER PRIMARY KEY); | ||
INSERT INTO Bits VALUES (0); | ||
INSERT INTO Bits VALUES (1); | ||
|
||
CREATE TEMP TABLE Nums AS SELECT | ||
b9.Bit * 512 + b8.Bit * 256 + b7.Bit * 128 + b6.Bit * 64 + b5.Bit * 32 + | ||
b4.Bit * 16 + b3.Bit * 8 + b2.Bit * 4 + b1.Bit * 2 + b0.Bit | ||
AS Num | ||
FROM Bits b9, Bits b8, Bits b7, Bits b6, Bits b5, | ||
Bits b4, Bits b3, Bits b2, Bits b1, Bits b0; | ||
|
||
CREATE TABLE foo (id INT, txt TEXT); | ||
BEGIN; | ||
INSERT INTO foo SELECT 0 + Num, 'Row ' || ( 0 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 1000 + Num, 'Row ' || ( 1000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 2000 + Num, 'Row ' || ( 2000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 3000 + Num, 'Row ' || ( 3000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 4000 + Num, 'Row ' || ( 4000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 5000 + Num, 'Row ' || ( 5000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 6000 + Num, 'Row ' || ( 6000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 7000 + Num, 'Row ' || ( 7000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 8000 + Num, 'Row ' || ( 8000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 9000 + Num, 'Row ' || ( 9000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 10000 + Num, 'Row ' || (10000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 11000 + Num, 'Row ' || (11000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 12000 + Num, 'Row ' || (12000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 13000 + Num, 'Row ' || (13000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 14000 + Num, 'Row ' || (14000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 15000 + Num, 'Row ' || (15000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 16000 + Num, 'Row ' || (16000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 17000 + Num, 'Row ' || (17000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 18000 + Num, 'Row ' || (18000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 19000 + Num, 'Row ' || (19000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 20000 + Num, 'Row ' || (20000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 21000 + Num, 'Row ' || (21000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 22000 + Num, 'Row ' || (22000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 23000 + Num, 'Row ' || (23000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 24000 + Num, 'Row ' || (24000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 25000 + Num, 'Row ' || (25000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 26000 + Num, 'Row ' || (26000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 27000 + Num, 'Row ' || (27000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 28000 + Num, 'Row ' || (28000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 29000 + Num, 'Row ' || (29000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 30000 + Num, 'Row ' || (30000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 31000 + Num, 'Row ' || (31000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 32000 + Num, 'Row ' || (32000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 33000 + Num, 'Row ' || (33000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 34000 + Num, 'Row ' || (34000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 35000 + Num, 'Row ' || (35000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 36000 + Num, 'Row ' || (36000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 37000 + Num, 'Row ' || (37000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 38000 + Num, 'Row ' || (38000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 39000 + Num, 'Row ' || (39000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 40000 + Num, 'Row ' || (40000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 41000 + Num, 'Row ' || (41000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 42000 + Num, 'Row ' || (42000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 43000 + Num, 'Row ' || (43000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 44000 + Num, 'Row ' || (44000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 45000 + Num, 'Row ' || (45000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 46000 + Num, 'Row ' || (46000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 47000 + Num, 'Row ' || (47000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 48000 + Num, 'Row ' || (48000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 49000 + Num, 'Row ' || (49000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 50000 + Num, 'Row ' || (50000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 51000 + Num, 'Row ' || (51000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 52000 + Num, 'Row ' || (52000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 53000 + Num, 'Row ' || (53000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 54000 + Num, 'Row ' || (54000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 55000 + Num, 'Row ' || (55000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 56000 + Num, 'Row ' || (56000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 57000 + Num, 'Row ' || (57000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 58000 + Num, 'Row ' || (58000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 59000 + Num, 'Row ' || (59000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 60000 + Num, 'Row ' || (60000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 61000 + Num, 'Row ' || (61000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 62000 + Num, 'Row ' || (62000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 63000 + Num, 'Row ' || (63000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 64000 + Num, 'Row ' || (64000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 65000 + Num, 'Row ' || (65000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 66000 + Num, 'Row ' || (66000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 67000 + Num, 'Row ' || (67000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 68000 + Num, 'Row ' || (68000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 69000 + Num, 'Row ' || (69000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 70000 + Num, 'Row ' || (70000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 71000 + Num, 'Row ' || (71000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 72000 + Num, 'Row ' || (72000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 73000 + Num, 'Row ' || (73000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 74000 + Num, 'Row ' || (74000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 75000 + Num, 'Row ' || (75000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 76000 + Num, 'Row ' || (76000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 77000 + Num, 'Row ' || (77000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 78000 + Num, 'Row ' || (78000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 79000 + Num, 'Row ' || (79000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 80000 + Num, 'Row ' || (80000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 81000 + Num, 'Row ' || (81000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 82000 + Num, 'Row ' || (82000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 83000 + Num, 'Row ' || (83000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 84000 + Num, 'Row ' || (84000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 85000 + Num, 'Row ' || (85000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 86000 + Num, 'Row ' || (86000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 87000 + Num, 'Row ' || (87000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 88000 + Num, 'Row ' || (88000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 89000 + Num, 'Row ' || (89000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 90000 + Num, 'Row ' || (90000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 91000 + Num, 'Row ' || (91000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 92000 + Num, 'Row ' || (92000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 93000 + Num, 'Row ' || (93000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 94000 + Num, 'Row ' || (94000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 95000 + Num, 'Row ' || (95000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 96000 + Num, 'Row ' || (96000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 97000 + Num, 'Row ' || (97000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 98000 + Num, 'Row ' || (98000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
INSERT INTO foo SELECT 99000 + Num, 'Row ' || (99000 + Num) FROM Nums WHERE Num BETWEEN 1 AND 1000; | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const sqlite3 = require('../lib/sqlite3'); | ||
const { readFileSync } = require('fs'); | ||
|
||
const db = new sqlite3.Database(''); | ||
db.serialize(() => { | ||
db.exec(readFileSync(`${__dirname}/select-data.sql`, 'utf8'), (err) => { | ||
if (err) | ||
throw err; | ||
console.time('db.each'); | ||
}); | ||
|
||
{ | ||
const results = []; | ||
db.each('SELECT * FROM foo', (err, row) => { | ||
if (err) | ||
throw err; | ||
results.push(row); | ||
}, () => { | ||
console.timeEnd('db.each'); | ||
console.time('db.all'); | ||
}); | ||
} | ||
|
||
db.all('SELECT * FROM foo', (err, rows) => { | ||
console.timeEnd('db.all'); | ||
if (err) | ||
throw err; | ||
}); | ||
|
||
db.close(); | ||
}); |