-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathdate.sql
34 lines (24 loc) · 1.4 KB
/
date.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
set extra_float_digits =0;
SELECT set_smlar_limit(0.6);
SELECT
t,
ARRAY(
SELECT
epoch2timestamp(v)::date
FROM
generate_series(1, t) as v
) AS v
INTO test_date
FROM
generate_series(1, 200) as t;
SELECT t, smlar(v, to_tsp_array('{10,9,8,7,6,5,4,3,2,1}')::date[]) AS s FROM test_date WHERE v % to_tsp_array('{10,9,8,7,6,5,4,3,2,1}')::date[] ORDER BY s DESC, t;
SELECT t, smlar(v, to_tsp_array('{50,49,8,7,6,5,4,33,2,1}')::date[]) AS s FROM test_date WHERE v % to_tsp_array('{50,49,8,7,6,5,4,33,2,1}')::date[] ORDER BY s DESC, t;
CREATE INDEX idx_test_date ON test_date USING gist (v _date_sml_ops);
SET enable_seqscan=off;
SELECT t, smlar(v, to_tsp_array('{10,9,8,7,6,5,4,3,2,1}')::date[]) AS s FROM test_date WHERE v % to_tsp_array('{10,9,8,7,6,5,4,3,2,1}')::date[] ORDER BY s DESC, t;
SELECT t, smlar(v, to_tsp_array('{50,49,8,7,6,5,4,33,2,1}')::date[]) AS s FROM test_date WHERE v % to_tsp_array('{50,49,8,7,6,5,4,33,2,1}')::date[] ORDER BY s DESC, t;
DROP INDEX idx_test_date;
CREATE INDEX idx_test_date ON test_date USING gin (v _date_sml_ops);
SELECT t, smlar(v, to_tsp_array('{10,9,8,7,6,5,4,3,2,1}')::date[]) AS s FROM test_date WHERE v % to_tsp_array('{10,9,8,7,6,5,4,3,2,1}')::date[] ORDER BY s DESC, t;
SELECT t, smlar(v, to_tsp_array('{50,49,8,7,6,5,4,33,2,1}')::date[]) AS s FROM test_date WHERE v % to_tsp_array('{50,49,8,7,6,5,4,33,2,1}')::date[] ORDER BY s DESC, t;
SET enable_seqscan=on;