1set enable_seqscan=off;
2CREATE TABLE test_uuid (
3	i uuid
4);
5INSERT INTO test_uuid VALUES
6	( '00000000-0000-0000-0000-000000000000' ),
7	( '299bc99f-2f79-4e3e-bfea-2cbfd62a7c27' ),
8	( '6264af33-0d43-4337-bf4e-43509b8a4be8' ),
9	( 'ce41c936-6acb-4feb-8c91-852a673e5a5c' ),
10	( 'd2ce731f-f2a8-4a2b-be37-8f0ba637427f' ),
11	( 'ffffffff-ffff-ffff-ffff-ffffffffffff' )
12;
13CREATE INDEX idx_uuid ON test_uuid USING gin (i);
14SELECT * FROM test_uuid WHERE i<'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
15                  i
16--------------------------------------
17 00000000-0000-0000-0000-000000000000
18 299bc99f-2f79-4e3e-bfea-2cbfd62a7c27
19 6264af33-0d43-4337-bf4e-43509b8a4be8
20(3 rows)
21
22SELECT * FROM test_uuid WHERE i<='ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
23                  i
24--------------------------------------
25 00000000-0000-0000-0000-000000000000
26 299bc99f-2f79-4e3e-bfea-2cbfd62a7c27
27 6264af33-0d43-4337-bf4e-43509b8a4be8
28 ce41c936-6acb-4feb-8c91-852a673e5a5c
29(4 rows)
30
31SELECT * FROM test_uuid WHERE i='ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
32                  i
33--------------------------------------
34 ce41c936-6acb-4feb-8c91-852a673e5a5c
35(1 row)
36
37SELECT * FROM test_uuid WHERE i>='ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
38                  i
39--------------------------------------
40 ce41c936-6acb-4feb-8c91-852a673e5a5c
41 d2ce731f-f2a8-4a2b-be37-8f0ba637427f
42 ffffffff-ffff-ffff-ffff-ffffffffffff
43(3 rows)
44
45SELECT * FROM test_uuid WHERE i>'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
46                  i
47--------------------------------------
48 d2ce731f-f2a8-4a2b-be37-8f0ba637427f
49 ffffffff-ffff-ffff-ffff-ffffffffffff
50(2 rows)
51
52EXPLAIN (COSTS OFF) SELECT * FROM test_uuid WHERE i<'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
53                                  QUERY PLAN
54------------------------------------------------------------------------------
55 Sort
56   Sort Key: i
57   ->  Bitmap Heap Scan on test_uuid
58         Recheck Cond: (i < 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
59         ->  Bitmap Index Scan on idx_uuid
60               Index Cond: (i < 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
61(6 rows)
62
63EXPLAIN (COSTS OFF) SELECT * FROM test_uuid WHERE i<='ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
64                                  QUERY PLAN
65-------------------------------------------------------------------------------
66 Sort
67   Sort Key: i
68   ->  Bitmap Heap Scan on test_uuid
69         Recheck Cond: (i <= 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
70         ->  Bitmap Index Scan on idx_uuid
71               Index Cond: (i <= 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
72(6 rows)
73
74EXPLAIN (COSTS OFF) SELECT * FROM test_uuid WHERE i='ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
75                               QUERY PLAN
76------------------------------------------------------------------------
77 Bitmap Heap Scan on test_uuid
78   Recheck Cond: (i = 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
79   ->  Bitmap Index Scan on idx_uuid
80         Index Cond: (i = 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
81(4 rows)
82
83EXPLAIN (COSTS OFF) SELECT * FROM test_uuid WHERE i>='ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
84                                  QUERY PLAN
85-------------------------------------------------------------------------------
86 Sort
87   Sort Key: i
88   ->  Bitmap Heap Scan on test_uuid
89         Recheck Cond: (i >= 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
90         ->  Bitmap Index Scan on idx_uuid
91               Index Cond: (i >= 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
92(6 rows)
93
94EXPLAIN (COSTS OFF) SELECT * FROM test_uuid WHERE i>'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid ORDER BY i;
95                                  QUERY PLAN
96------------------------------------------------------------------------------
97 Sort
98   Sort Key: i
99   ->  Bitmap Heap Scan on test_uuid
100         Recheck Cond: (i > 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
101         ->  Bitmap Index Scan on idx_uuid
102               Index Cond: (i > 'ce41c936-6acb-4feb-8c91-852a673e5a5c'::uuid)
103(6 rows)
104
105