mirror of
https://github.com/postgres/postgres.git
synced 2025-12-24 06:01:07 +03:00
Using the just-added infrastructure, extend btree_gin to support cross-type operators in its other opclasses. All of the cross-type comparison operators supported by the core btree opclasses for these datatypes are now available for btree_gin indexes as well. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com> Discussion: https://postgr.es/m/262624.1738460652@sss.pgh.pa.us
157 lines
3.2 KiB
Plaintext
157 lines
3.2 KiB
Plaintext
set enable_seqscan=off;
|
|
CREATE TABLE test_name (
|
|
i name
|
|
);
|
|
INSERT INTO test_name VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
|
|
CREATE INDEX idx_name ON test_name USING gin (i);
|
|
SELECT * FROM test_name WHERE i<'abc' ORDER BY i;
|
|
i
|
|
-----
|
|
a
|
|
ab
|
|
abb
|
|
(3 rows)
|
|
|
|
SELECT * FROM test_name WHERE i<='abc' ORDER BY i;
|
|
i
|
|
-----
|
|
a
|
|
ab
|
|
abb
|
|
abc
|
|
(4 rows)
|
|
|
|
SELECT * FROM test_name WHERE i='abc' ORDER BY i;
|
|
i
|
|
-----
|
|
abc
|
|
(1 row)
|
|
|
|
SELECT * FROM test_name WHERE i>='abc' ORDER BY i;
|
|
i
|
|
-----
|
|
abc
|
|
axy
|
|
xyz
|
|
(3 rows)
|
|
|
|
SELECT * FROM test_name WHERE i>'abc' ORDER BY i;
|
|
i
|
|
-----
|
|
axy
|
|
xyz
|
|
(2 rows)
|
|
|
|
EXPLAIN (COSTS OFF) SELECT * FROM test_name WHERE i<'abc' ORDER BY i;
|
|
QUERY PLAN
|
|
---------------------------------------------
|
|
Sort
|
|
Sort Key: i
|
|
-> Bitmap Heap Scan on test_name
|
|
Recheck Cond: (i < 'abc'::name)
|
|
-> Bitmap Index Scan on idx_name
|
|
Index Cond: (i < 'abc'::name)
|
|
(6 rows)
|
|
|
|
EXPLAIN (COSTS OFF) SELECT * FROM test_name WHERE i<='abc' ORDER BY i;
|
|
QUERY PLAN
|
|
----------------------------------------------
|
|
Sort
|
|
Sort Key: i
|
|
-> Bitmap Heap Scan on test_name
|
|
Recheck Cond: (i <= 'abc'::name)
|
|
-> Bitmap Index Scan on idx_name
|
|
Index Cond: (i <= 'abc'::name)
|
|
(6 rows)
|
|
|
|
EXPLAIN (COSTS OFF) SELECT * FROM test_name WHERE i='abc' ORDER BY i;
|
|
QUERY PLAN
|
|
---------------------------------------
|
|
Bitmap Heap Scan on test_name
|
|
Recheck Cond: (i = 'abc'::name)
|
|
-> Bitmap Index Scan on idx_name
|
|
Index Cond: (i = 'abc'::name)
|
|
(4 rows)
|
|
|
|
EXPLAIN (COSTS OFF) SELECT * FROM test_name WHERE i>='abc' ORDER BY i;
|
|
QUERY PLAN
|
|
----------------------------------------------
|
|
Sort
|
|
Sort Key: i
|
|
-> Bitmap Heap Scan on test_name
|
|
Recheck Cond: (i >= 'abc'::name)
|
|
-> Bitmap Index Scan on idx_name
|
|
Index Cond: (i >= 'abc'::name)
|
|
(6 rows)
|
|
|
|
EXPLAIN (COSTS OFF) SELECT * FROM test_name WHERE i>'abc' ORDER BY i;
|
|
QUERY PLAN
|
|
---------------------------------------------
|
|
Sort
|
|
Sort Key: i
|
|
-> Bitmap Heap Scan on test_name
|
|
Recheck Cond: (i > 'abc'::name)
|
|
-> Bitmap Index Scan on idx_name
|
|
Index Cond: (i > 'abc'::name)
|
|
(6 rows)
|
|
|
|
explain (costs off)
|
|
SELECT * FROM test_name WHERE i<'abc'::text ORDER BY i;
|
|
QUERY PLAN
|
|
---------------------------------------------
|
|
Sort
|
|
Sort Key: i
|
|
-> Bitmap Heap Scan on test_name
|
|
Recheck Cond: (i < 'abc'::text)
|
|
-> Bitmap Index Scan on idx_name
|
|
Index Cond: (i < 'abc'::text)
|
|
(6 rows)
|
|
|
|
SELECT * FROM test_name WHERE i<'abc'::text ORDER BY i;
|
|
i
|
|
-----
|
|
a
|
|
ab
|
|
abb
|
|
(3 rows)
|
|
|
|
SELECT * FROM test_name WHERE i<='abc'::text ORDER BY i;
|
|
i
|
|
-----
|
|
a
|
|
ab
|
|
abb
|
|
abc
|
|
(4 rows)
|
|
|
|
SELECT * FROM test_name WHERE i='abc'::text ORDER BY i;
|
|
i
|
|
-----
|
|
abc
|
|
(1 row)
|
|
|
|
SELECT * FROM test_name WHERE i>='abc'::text ORDER BY i;
|
|
i
|
|
-----
|
|
abc
|
|
axy
|
|
xyz
|
|
(3 rows)
|
|
|
|
SELECT * FROM test_name WHERE i>'abc'::text ORDER BY i;
|
|
i
|
|
-----
|
|
axy
|
|
xyz
|
|
(2 rows)
|
|
|
|
SELECT * FROM test_name WHERE i<=repeat('abc', 100) ORDER BY i;
|
|
i
|
|
-----
|
|
a
|
|
ab
|
|
abb
|
|
abc
|
|
(4 rows)
|
|
|