CREATE TABLE t (id INTEGER PRIMARY KEY, name TEXT);

SELECT '--- Populating table...';
BEGIN TRANSACTION;
INSERT INTO t (name)             VALUES ('');
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (id, NAME) VALUES (1000000, '');
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (id, NAME) VALUES (2000000, '');
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (id, NAME) VALUES (4000000, '');
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (id, NAME) VALUES (8000000, '');
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (id, NAME) VALUES (16000000, '');
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (id, NAME) VALUES (32000000, '');
INSERT INTO t (name) SELECT name FROM t;
INSERT INTO t (name) SELECT name FROM t;
END TRANSACTION;

SELECT '--- Query #1: measure time to select with 150 BETWEEN clauses with equal min/max -> SLOW!';
.timer on
SELECT COUNT(*) FROM t WHERE
   id BETWEEN     100 AND     100 OR id BETWEEN     120 AND     120 OR id BETWEEN     140 AND    140
OR id BETWEEN     160 AND     160 OR id BETWEEN     180 AND     180 OR id BETWEEN     200 AND    200
OR id BETWEEN     220 AND     220 OR id BETWEEN     240 AND     240 OR id BETWEEN     260 AND    260
OR id BETWEEN     280 AND     280 OR id BETWEEN     300 AND     300 OR id BETWEEN     320 AND    320
OR id BETWEEN     340 AND     340 OR id BETWEEN     360 AND     360 OR id BETWEEN     380 AND    380
OR id BETWEEN     400 AND     400 OR id BETWEEN     420 AND     420 OR id BETWEEN     440 AND    440
OR id BETWEEN     460 AND     460 OR id BETWEEN     480 AND     480 OR id BETWEEN     500 AND    500
OR id BETWEEN     520 AND     520 OR id BETWEEN     540 AND     540 OR id BETWEEN     560 AND    560
OR id BETWEEN     580 AND     580 OR id BETWEEN     600 AND     600 OR id BETWEEN     620 AND    620
OR id BETWEEN     640 AND     640 OR id BETWEEN     660 AND     660 OR id BETWEEN     680 AND    680
OR id BETWEEN     700 AND     700 OR id BETWEEN     720 AND     720 OR id BETWEEN     740 AND    740
OR id BETWEEN     760 AND     760 OR id BETWEEN     780 AND     780 OR id BETWEEN     800 AND    800
OR id BETWEEN     820 AND     820 OR id BETWEEN     840 AND     840 OR id BETWEEN     860 AND    860
OR id BETWEEN     880 AND     880 OR id BETWEEN     900 AND     900 OR id BETWEEN     920 AND    920
OR id BETWEEN     940 AND     940 OR id BETWEEN     960 AND     960 OR id BETWEEN     980 AND    980
OR id BETWEEN    1000 AND    1000 OR id BETWEEN    1020 AND    1020 OR id BETWEEN    1040 AND    1040
OR id BETWEEN    1060 AND    1060 OR id BETWEEN    1080 AND    1080 OR id BETWEEN    1100 AND    1100
OR id BETWEEN    1120 AND    1120 OR id BETWEEN    1140 AND    1140 OR id BETWEEN    1160 AND    1160
OR id BETWEEN    1180 AND    1180 OR id BETWEEN    1200 AND    1200 OR id BETWEEN    1220 AND    1220
OR id BETWEEN 1100000 AND 1100000 OR id BETWEEN 1100020 AND 1100020 OR id BETWEEN 1100040 AND 1100040
OR id BETWEEN 1100060 AND 1100060 OR id BETWEEN 1100080 AND 1100080 OR id BETWEEN 1100100 AND 1100100
OR id BETWEEN 1100120 AND 1100120 OR id BETWEEN 1100140 AND 1100140 OR id BETWEEN 1100160 AND 1100160
OR id BETWEEN 1100180 AND 1100180 OR id BETWEEN 1100200 AND 1100200 OR id BETWEEN 1100220 AND 1100220
OR id BETWEEN 1100240 AND 1100240 OR id BETWEEN 1100260 AND 1100260 OR id BETWEEN 1100280 AND 1100280
OR id BETWEEN 1100300 AND 1100300 OR id BETWEEN 1100320 AND 1100320 OR id BETWEEN 1100340 AND 1100340
OR id BETWEEN 1100360 AND 1100360 OR id BETWEEN 1100380 AND 1100380 OR id BETWEEN 1100400 AND 1100400
OR id BETWEEN 1100420 AND 1100420 OR id BETWEEN 1100440 AND 1100440 OR id BETWEEN 1100460 AND 1100460
OR id BETWEEN 1100480 AND 1100480 OR id BETWEEN 1100500 AND 1100500 OR id BETWEEN 1100520 AND 1100520
OR id BETWEEN 1100540 AND 1100540 OR id BETWEEN 1100560 AND 1100560 OR id BETWEEN 1100580 AND 1100580
OR id BETWEEN 1100600 AND 1100600 OR id BETWEEN 1100620 AND 1100620 OR id BETWEEN 1100640 AND 1100640
OR id BETWEEN 1100660 AND 1100660 OR id BETWEEN 1100680 AND 1100680 OR id BETWEEN 1100700 AND 1100700
OR id BETWEEN 1100720 AND 1100720 OR id BETWEEN 1100740 AND 1100740 OR id BETWEEN 1100760 AND 1100760
OR id BETWEEN 1100780 AND 1100780 OR id BETWEEN 1100800 AND 1100800 OR id BETWEEN 1100820 AND 1100820
OR id BETWEEN 1100840 AND 1100840 OR id BETWEEN 1100860 AND 1100860 OR id BETWEEN 1100880 AND 1100880
OR id BETWEEN 1100900 AND 1100900 OR id BETWEEN 1100920 AND 1100920 OR id BETWEEN 1100940 AND 1100940
OR id BETWEEN 1100960 AND 1100960 OR id BETWEEN 1100980 AND 1100980 OR id BETWEEN 1101000 AND 1101000
OR id BETWEEN 1101020 AND 1101020 OR id BETWEEN 1101040 AND 1101040 OR id BETWEEN 1101060 AND 1101060
OR id BETWEEN 1101080 AND 1101080 OR id BETWEEN 1101100 AND 1101100 OR id BETWEEN 1101120 AND 1101120
OR id BETWEEN 1101140 AND 1101140 OR id BETWEEN 1101160 AND 1101160 OR id BETWEEN 1101180 AND 1101180
OR id BETWEEN 1101200 AND 1101200 OR id BETWEEN 1101220 AND 1101220 OR id BETWEEN 1101240 AND 1101240
OR id BETWEEN 1101260 AND 1101260 OR id BETWEEN 1101280 AND 1101280 OR id BETWEEN 1101300 AND 1101300
OR id BETWEEN 1101320 AND 1101320 OR id BETWEEN 1101340 AND 1101340 OR id BETWEEN 1101360 AND 1101360
OR id BETWEEN 1101380 AND 1101380 OR id BETWEEN 1101400 AND 1101400 OR id BETWEEN 1101420 AND 1101420
OR id BETWEEN 1101440 AND 1101440 OR id BETWEEN 1101460 AND 1101460 OR id BETWEEN 1101480 AND 1101480
OR id BETWEEN 1101500 AND 1101500 OR id BETWEEN 1101520 AND 1101520 OR id BETWEEN 1101540 AND 1101540
OR id BETWEEN 1101560 AND 1101560 OR id BETWEEN 1101580 AND 1101580 OR id BETWEEN 1101600 AND 1101600
OR id BETWEEN 1101620 AND 1101620 OR id BETWEEN 1101640 AND 1101640 OR id BETWEEN 1101660 AND 1101660
OR id BETWEEN 1101680 AND 1101680 OR id BETWEEN 1101700 AND 1101700 OR id BETWEEN 1101720 AND 1101720
OR id BETWEEN 1101740 AND 1101740 OR id BETWEEN 1101760 AND 1101760 OR id BETWEEN 1101780 AND 1101780
OR id BETWEEN 1101800 AND 1101800 OR id BETWEEN 1101820 AND 1101820 OR id BETWEEN 1101840 AND 1101840
;
.timer off

SELECT '--- Query #2: measure time to select using: IN (...150 values...)  --> equivalent and FAST!';
.timer on
SELECT COUNT(*) FROM t WHERE id IN (
    100,     120,     140,     160,     180,
    200,     220,     240,     260,     280,
    300,     320,     340,     360,     380,
    400,     420,     440,     460,     480,
    500,     520,     540,     560,     580,
    600,     620,     640,     660,     680,
    700,     720,     740,     760,     780,
    800,     820,     840,     860,     880,
    900,     920,     940,     960,     980,
   1000,    1020,    1040,    1060,    1080,
   1100,    1120,    1140,    1160,    1180,
   1200,    1220, 1100000, 1100020, 1100040,
1100060, 1100080, 1100100, 1100120, 1100140,
1100160, 1100180, 1100200, 1100220, 1100240,
1100260, 1100280, 1100300, 1100320, 1100340,
1100360, 1100380, 1100400, 1100420, 1100440,
1100460, 1100480, 1100500, 1100520, 1100540,
1100560, 1100580, 1100600, 1100620, 1100640,
1100660, 1100680, 1100700, 1100720, 1100740,
1100760, 1100780, 1100800, 1100820, 1100840,
1100860, 1100880, 1100900, 1100920, 1100940,
1100960, 1100980, 1101000, 1101020, 1101040,
1101060, 1101080, 1101100, 1101120, 1101140,
1101160, 1101180, 1101200, 1101220, 1101240,
1101260, 1101280, 1101300, 1101320, 1101340,
1101360, 1101380, 1101400, 1101420, 1101440,
1101460, 1101480, 1101500, 1101520, 1101540,
1101560, 1101580, 1101600, 1101620, 1101640,
1101660, 1101680, 1101700, 1101720, 1101740,
1101760, 1101780, 1101800, 1101820, 1101840
);
