Skip to content

Commit 1140013

Browse files
committed
gin_hstore_bytea_ops - non collation-aware version of default hstore GIN index.
1 parent d39afc3 commit 1140013

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MODULE_big = hstore_ops
44
OBJS = hstore_compat.o hstore_ops.o
55

66
EXTENSION = hstore_ops
7-
DATA = hstore_ops--1.0.sql
7+
DATA = hstore_ops--1.1.sql hstore_ops--1.0--1.1.sql
88

99
REGRESS = hstore_ops
1010

README.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ hstore_ops - better operator class for hstore
22
=============================================
33

44
hstore_ops extension provides another implementation of GIN index (opclass)
5-
for hstore. It provides smaller index and faster @> operator queries than
6-
default GIN opclass. However, queries containing ?, ?|, ?& operators could
7-
become a little slower.
5+
for hstore - gin_hstore_hash_ops. It provides smaller index and faster @>
6+
operator queries than default GIN opclass. However, queries containing ?,
7+
?|, ?& operators could become a bit slower.
88

99
Idea of this opclass is to use composite GIN key which consists of hashes
1010
of hstore key and value. Thus, search for @> operator is possible as simple
@@ -14,6 +14,12 @@ every kind of search, because of possible hash collision. Hashing provides
1414
small size of index, mixing key and value into same GIN key provides high
1515
performance for @> search operator.
1616

17+
Also hstore_ops extension contains gin_hstore_bytea_ops - variation of
18+
standard GIN opclass for hstore where collation key comparison is replaced
19+
with per-byte comparison. This change doesn't affect any functionality,
20+
just makes index work faster when collation comparison is slow.
21+
gin_hstore_bytea_ops was introduced in version 1.1.
22+
1723
Authors
1824
-------
1925

@@ -52,12 +58,17 @@ Typical installation procedure may look like this:
5258
$ make USE_PGXS=1 installcheck
5359
$ psql DB -c "CREATE EXTENSION hstore_ops;"
5460

61+
If you used hstore_ops 1.0 then replace last command to upgrade to 1.1.
62+
63+
$ psql DB -c "ALTER EXTENSION hstore_ops UPDATE TO '1.1';"
64+
5565
Usage
5666
-----
5767

58-
Just create index on hstore column using following command.
68+
Just create index on hstore column using one of following commands.
5969

6070
CREATE INDEX index_name ON table_name USING GIN (column_name gin_hstore_hash_ops);
71+
CREATE INDEX index_name ON table_name USING GIN (column_name gin_hstore_bytea_ops);
6172

6273
Index will be automatically used for search on @>, ?, ?|, ?& operators on this
6374
column.

hstore_ops--1.0--1.1.sql

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* contrib/hstore_ops/hstore_ops--1.0--1.1.sql */
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use "ALTER EXTENSION hstore_ops UPDATE TO '1.1'" to load this file. \quit
5+
6+
CREATE OPERATOR CLASS gin_hstore_bytea_ops
7+
FOR TYPE hstore USING gin
8+
AS
9+
OPERATOR 7 @>,
10+
OPERATOR 9 ?(hstore,text),
11+
OPERATOR 10 ?|(hstore,text[]),
12+
OPERATOR 11 ?&(hstore,text[]),
13+
FUNCTION 1 byteacmp(bytea,bytea),
14+
FUNCTION 2 gin_extract_hstore(internal, internal),
15+
FUNCTION 3 gin_extract_hstore_query(internal, internal, int2, internal, internal),
16+
FUNCTION 4 gin_consistent_hstore(internal, int2, internal, int4, internal, internal),
17+
STORAGE bytea;

hstore_ops--1.0.sql renamed to hstore_ops--1.1.sql

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* contrib/hstore/hstore_ops--1.0.sql */
1+
/* contrib/hstore_ops/hstore_ops--1.1.sql */
22

33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use "CREATE EXTENSION hstore_ops" to load this file. \quit
@@ -41,3 +41,16 @@ AS
4141
FUNCTION 4 gin_consistent_hstore_hash(internal, int2, internal, int4, internal, internal),
4242
FUNCTION 5 gin_compare_partial_hstore_hash(int8, int8, int2, internal),
4343
STORAGE int8;
44+
45+
CREATE OPERATOR CLASS gin_hstore_bytea_ops
46+
FOR TYPE hstore USING gin
47+
AS
48+
OPERATOR 7 @>,
49+
OPERATOR 9 ?(hstore,text),
50+
OPERATOR 10 ?|(hstore,text[]),
51+
OPERATOR 11 ?&(hstore,text[]),
52+
FUNCTION 1 byteacmp(bytea,bytea),
53+
FUNCTION 2 gin_extract_hstore(internal, internal),
54+
FUNCTION 3 gin_extract_hstore_query(internal, internal, int2, internal, internal),
55+
FUNCTION 4 gin_consistent_hstore(internal, int2, internal, int4, internal, internal),
56+
STORAGE bytea;

hstore_ops.control

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# hstore_ops extension
22
comment = 'extra operator class for hstore extension'
3-
default_version = '1.0'
3+
default_version = '1.1'
44
module_pathname = '$libdir/hstore_ops'
55
relocatable = true
66
requires = 'hstore'

0 commit comments

Comments
 (0)