[Groonga-commit] pgroonga/pgroonga at bc8b86f [master] Add v2 compatible operators to pgroonga.varchar_array_ops

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Tue May 2 17:47:58 JST 2017


Kouhei Sutou	2017-05-02 17:47:58 +0900 (Tue, 02 May 2017)

  New Revision: bc8b86f348c0183aa60afbca36f0ac840ce5ce32
  https://github.com/pgroonga/pgroonga/commit/bc8b86f348c0183aa60afbca36f0ac840ce5ce32

  Message:
    Add v2 compatible operators to pgroonga.varchar_array_ops

  Added files:
    expected/match/varchar-array/compatibility/v1/match-v2/bitmapscan.out
    expected/match/varchar-array/compatibility/v1/match-v2/indexscan.out
    expected/match/varchar-array/compatibility/v1/match-v2/seqscan.out
    sql/match/varchar-array/compatibility/v1/match-v2/bitmapscan.sql
    sql/match/varchar-array/compatibility/v1/match-v2/indexscan.sql
    sql/match/varchar-array/compatibility/v1/match-v2/seqscan.sql
  Modified files:
    data/pgroonga--1.2.0--1.2.1.sql
    data/pgroonga.sql

  Modified: data/pgroonga--1.2.0--1.2.1.sql (+5 -0)
===================================================================
--- data/pgroonga--1.2.0--1.2.1.sql    2017-05-02 17:44:25 +0900 (6ed1aa4)
+++ data/pgroonga--1.2.0--1.2.1.sql    2017-05-02 17:47:58 +0900 (86f4885)
@@ -360,3 +360,8 @@ CREATE OPERATOR CLASS pgroonga.varchar_array_ops_v2 FOR TYPE varchar[]
 	USING pgroonga AS
 		OPERATOR 8 %% (varchar[], varchar), -- For backward compatibility
 		OPERATOR 12 &@ (varchar[], varchar);
+
+-- Add v2 compatible operators to full text search ops for varchar
+ALTER OPERATOR FAMILY pgroonga.varchar_array_ops USING pgroonga
+	ADD
+		OPERATOR 12 &@ (varchar[], varchar);

  Modified: data/pgroonga.sql (+2 -1)
===================================================================
--- data/pgroonga.sql    2017-05-02 17:44:25 +0900 (237f43f)
+++ data/pgroonga.sql    2017-05-02 17:47:58 +0900 (68a4b58)
@@ -797,7 +797,8 @@ CREATE OPERATOR CLASS pgroonga.varchar_array_ops
 	DEFAULT
 	FOR TYPE varchar[]
 	USING pgroonga AS
-		OPERATOR 8 %% (varchar[], varchar);
+		OPERATOR 8 %% (varchar[], varchar),
+		OPERATOR 12 &@ (varchar[], varchar);
 
 CREATE OPERATOR CLASS pgroonga.bool_ops DEFAULT FOR TYPE bool
 	USING pgroonga AS

  Added: expected/match/varchar-array/compatibility/v1/match-v2/bitmapscan.out (+34 -0) 100644
===================================================================
--- /dev/null
+++ expected/match/varchar-array/compatibility/v1/match-v2/bitmapscan.out    2017-05-02 17:47:58 +0900 (19ad7d5)
@@ -0,0 +1,34 @@
+CREATE TABLE memos (
+  title text,
+  tags varchar(1023)[]
+);
+INSERT INTO memos VALUES ('PostgreSQL', ARRAY['PostgreSQL']);
+INSERT INTO memos VALUES ('Groonga', ARRAY['Groonga']);
+INSERT INTO memos VALUES ('PGroonga', ARRAY['PostgreSQL', 'Groonga']);
+CREATE INDEX pgroonga_memos_index ON memos
+  USING pgroonga (tags pgroonga.varchar_array_ops);
+SET enable_seqscan = off;
+SET enable_indexscan = off;
+SET enable_bitmapscan = on;
+EXPLAIN (COSTS OFF)
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+                         QUERY PLAN                         
+------------------------------------------------------------
+ Bitmap Heap Scan on memos
+   Recheck Cond: (tags &@ 'Groonga'::character varying)
+   ->  Bitmap Index Scan on pgroonga_memos_index
+         Index Cond: (tags &@ 'Groonga'::character varying)
+(4 rows)
+
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+  title   |         tags         
+----------+----------------------
+ Groonga  | {Groonga}
+ PGroonga | {PostgreSQL,Groonga}
+(2 rows)
+
+DROP TABLE memos;

  Added: expected/match/varchar-array/compatibility/v1/match-v2/indexscan.out (+32 -0) 100644
===================================================================
--- /dev/null
+++ expected/match/varchar-array/compatibility/v1/match-v2/indexscan.out    2017-05-02 17:47:58 +0900 (4672067)
@@ -0,0 +1,32 @@
+CREATE TABLE memos (
+  title text,
+  tags varchar(1023)[]
+);
+INSERT INTO memos VALUES ('PostgreSQL', ARRAY['PostgreSQL']);
+INSERT INTO memos VALUES ('Groonga', ARRAY['Groonga']);
+INSERT INTO memos VALUES ('PGroonga', ARRAY['PostgreSQL', 'Groonga']);
+CREATE INDEX pgroonga_memos_index ON memos
+  USING pgroonga (tags pgroonga.varchar_array_ops);
+SET enable_seqscan = off;
+SET enable_indexscan = on;
+SET enable_bitmapscan = off;
+EXPLAIN (COSTS OFF)
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+                      QUERY PLAN                      
+------------------------------------------------------
+ Index Scan using pgroonga_memos_index on memos
+   Index Cond: (tags &@ 'Groonga'::character varying)
+(2 rows)
+
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+  title   |         tags         
+----------+----------------------
+ Groonga  | {Groonga}
+ PGroonga | {PostgreSQL,Groonga}
+(2 rows)
+
+DROP TABLE memos;

  Added: expected/match/varchar-array/compatibility/v1/match-v2/seqscan.out (+22 -0) 100644
===================================================================
--- /dev/null
+++ expected/match/varchar-array/compatibility/v1/match-v2/seqscan.out    2017-05-02 17:47:58 +0900 (4ff2f3b)
@@ -0,0 +1,22 @@
+CREATE TABLE memos (
+  title text,
+  tags varchar(1023)[]
+);
+INSERT INTO memos VALUES ('PostgreSQL', ARRAY['PostgreSQL']);
+INSERT INTO memos VALUES ('Groonga', ARRAY['Groonga']);
+INSERT INTO memos VALUES ('PGroonga', ARRAY['PostgreSQL', 'Groonga']);
+CREATE INDEX pgroonga_memos_index ON memos
+  USING pgroonga (tags pgroonga.varchar_array_ops);
+SET enable_seqscan = on;
+SET enable_indexscan = off;
+SET enable_bitmapscan = off;
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+  title   |         tags         
+----------+----------------------
+ Groonga  | {Groonga}
+ PGroonga | {PostgreSQL,Groonga}
+(2 rows)
+
+DROP TABLE memos;

  Added: sql/match/varchar-array/compatibility/v1/match-v2/bitmapscan.sql (+26 -0) 100644
===================================================================
--- /dev/null
+++ sql/match/varchar-array/compatibility/v1/match-v2/bitmapscan.sql    2017-05-02 17:47:58 +0900 (7f95ae0)
@@ -0,0 +1,26 @@
+CREATE TABLE memos (
+  title text,
+  tags varchar(1023)[]
+);
+
+INSERT INTO memos VALUES ('PostgreSQL', ARRAY['PostgreSQL']);
+INSERT INTO memos VALUES ('Groonga', ARRAY['Groonga']);
+INSERT INTO memos VALUES ('PGroonga', ARRAY['PostgreSQL', 'Groonga']);
+
+CREATE INDEX pgroonga_memos_index ON memos
+  USING pgroonga (tags pgroonga.varchar_array_ops);
+
+SET enable_seqscan = off;
+SET enable_indexscan = off;
+SET enable_bitmapscan = on;
+
+EXPLAIN (COSTS OFF)
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+
+DROP TABLE memos;

  Added: sql/match/varchar-array/compatibility/v1/match-v2/indexscan.sql (+26 -0) 100644
===================================================================
--- /dev/null
+++ sql/match/varchar-array/compatibility/v1/match-v2/indexscan.sql    2017-05-02 17:47:58 +0900 (dd9f486)
@@ -0,0 +1,26 @@
+CREATE TABLE memos (
+  title text,
+  tags varchar(1023)[]
+);
+
+INSERT INTO memos VALUES ('PostgreSQL', ARRAY['PostgreSQL']);
+INSERT INTO memos VALUES ('Groonga', ARRAY['Groonga']);
+INSERT INTO memos VALUES ('PGroonga', ARRAY['PostgreSQL', 'Groonga']);
+
+CREATE INDEX pgroonga_memos_index ON memos
+  USING pgroonga (tags pgroonga.varchar_array_ops);
+
+SET enable_seqscan = off;
+SET enable_indexscan = on;
+SET enable_bitmapscan = off;
+
+EXPLAIN (COSTS OFF)
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+
+DROP TABLE memos;

  Added: sql/match/varchar-array/compatibility/v1/match-v2/seqscan.sql (+21 -0) 100644
===================================================================
--- /dev/null
+++ sql/match/varchar-array/compatibility/v1/match-v2/seqscan.sql    2017-05-02 17:47:58 +0900 (cd344c8)
@@ -0,0 +1,21 @@
+CREATE TABLE memos (
+  title text,
+  tags varchar(1023)[]
+);
+
+INSERT INTO memos VALUES ('PostgreSQL', ARRAY['PostgreSQL']);
+INSERT INTO memos VALUES ('Groonga', ARRAY['Groonga']);
+INSERT INTO memos VALUES ('PGroonga', ARRAY['PostgreSQL', 'Groonga']);
+
+CREATE INDEX pgroonga_memos_index ON memos
+  USING pgroonga (tags pgroonga.varchar_array_ops);
+
+SET enable_seqscan = on;
+SET enable_indexscan = off;
+SET enable_bitmapscan = off;
+
+SELECT title, tags
+  FROM memos
+ WHERE tags &@ 'Groonga';
+
+DROP TABLE memos;
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る