File: text.sql

package info (click to toggle)
postgresql-rum 1.3.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,956 kB
  • sloc: ansic: 29,184; sql: 6,614; perl: 546; python: 97; makefile: 68; sh: 64
file content (86 lines) | stat: -rw-r--r-- 3,317 bytes parent folder | download | duplicates (3)
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
set enable_seqscan=off;

CREATE TABLE test_text (
	i text
);

INSERT INTO test_text VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');

CREATE INDEX idx_text ON test_text USING rum (i);

SELECT * FROM test_text WHERE i<'abc' ORDER BY i;
SELECT * FROM test_text WHERE i<='abc' ORDER BY i;
SELECT * FROM test_text WHERE i='abc' ORDER BY i;
SELECT * FROM test_text WHERE i>='abc' ORDER BY i;
SELECT * FROM test_text WHERE i>'abc' ORDER BY i;

CREATE TABLE test_text_o AS SELECT id::text, t FROM tsts;

SELECT id FROM test_text_o WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
SELECT id FROM test_text_o WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;

CREATE INDEX test_text_o_idx ON test_text_o USING rum
    (t rum_tsvector_addon_ops, id)
    WITH (attach = 'id', to = 't');

RESET enable_indexscan;
RESET enable_indexonlyscan;
SET enable_bitmapscan=OFF;
SET enable_seqscan = off;

EXPLAIN (costs off)
SELECT id FROM test_text_o WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
SELECT id FROM test_text_o WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
EXPLAIN (costs off)
SELECT id FROM test_text_o WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;
SELECT id FROM test_text_o WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;

CREATE TABLE test_text_a AS SELECT id::text, t FROM tsts;

-- Should fail, temporarly it isn't allowed to order an index over pass-by-reference column
CREATE INDEX test_text_a_idx ON test_text_a USING rum
	(t rum_tsvector_addon_ops, id)
	WITH (attach = 'id', to = 't', order_by_attach='t');

EXPLAIN (costs off)
SELECT count(*) FROM test_text_a WHERE id < '400';
SELECT count(*) FROM test_text_a WHERE id < '400';

EXPLAIN (costs off)
SELECT id FROM test_text_a WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
SELECT id FROM test_text_a WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
EXPLAIN (costs off)
SELECT id FROM test_text_a WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;
SELECT id FROM test_text_a WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;

CREATE TABLE test_text_h_o AS SELECT id::text, t FROM tsts;

CREATE INDEX test_text_h_o_idx ON test_text_h_o USING rum
	(t rum_tsvector_hash_addon_ops, id)
	WITH (attach = 'id', to = 't');

EXPLAIN (costs off)
SELECT id FROM test_text_h_o WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
SELECT id FROM test_text_h_o WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
EXPLAIN (costs off)
SELECT id FROM test_text_h_o WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;
SELECT id FROM test_text_h_o WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;

CREATE TABLE test_text_h_a AS SELECT id::text, t FROM tsts;

-- Should fail, temporarly it isn't allowed to order an index over pass-by-reference column
CREATE INDEX test_text_h_a_idx ON test_text_h_a USING rum
	(t rum_tsvector_hash_addon_ops, id)
	WITH (attach = 'id', to = 't', order_by_attach='t');

EXPLAIN (costs off)
SELECT count(*) FROM test_text_h_a WHERE id < '400';
SELECT count(*) FROM test_text_h_a WHERE id < '400';

EXPLAIN (costs off)
SELECT id FROM test_text_h_a WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
SELECT id FROM test_text_h_a WHERE  t @@ 'wr&qh' AND id <= '400' ORDER BY id;
EXPLAIN (costs off)
SELECT id FROM test_text_h_a WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;
SELECT id FROM test_text_h_a WHERE  t @@ 'wr&qh' AND id >= '400' ORDER BY id;