Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit875154c

Browse files
df7cbmsdemlei
authored andcommitted
Implement inequality index lookups
1 parenteb27a2f commit875154c

File tree

5 files changed

+141
-0
lines changed

5 files changed

+141
-0
lines changed

‎expected/moc100.out‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
6565
Buffers: shared hit=114
6666
(4 rows)
6767

68+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
69+
SELECT * FROM moc100 WHERE coverage = '0/0-11';
70+
QUERY PLAN
71+
--------------------------------------------------------------------------------
72+
Seq Scan on moc100 (cost=0.00..6.26 rows=1 width=96) (actual rows=23 loops=1)
73+
Filter: (coverage = '0/0-11'::smoc)
74+
Rows Removed by Filter: 78
75+
Buffers: shared hit=59
76+
(4 rows)
77+
6878
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
6979
SELECT * FROM moc100 WHERE coverage = '6/43225,43227';
7080
QUERY PLAN
@@ -85,6 +95,36 @@ EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
8595
Buffers: shared hit=59
8696
(4 rows)
8797

98+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
99+
SELECT * FROM moc100 WHERE coverage <> '0/0-11';
100+
QUERY PLAN
101+
----------------------------------------------------------------------------------
102+
Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=78 loops=1)
103+
Filter: (coverage <> '0/0-11'::smoc)
104+
Rows Removed by Filter: 23
105+
Buffers: shared hit=59
106+
(4 rows)
107+
108+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
109+
SELECT * FROM moc100 WHERE coverage <> '6/43225,43227';
110+
QUERY PLAN
111+
-----------------------------------------------------------------------------------
112+
Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1)
113+
Filter: (coverage <> '6/43225 43227'::smoc)
114+
Rows Removed by Filter: 1
115+
Buffers: shared hit=59
116+
(4 rows)
117+
118+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
119+
SELECT * FROM moc100 WHERE coverage <> '0/';
120+
QUERY PLAN
121+
-----------------------------------------------------------------------------------
122+
Seq Scan on moc100 (cost=0.00..6.26 rows=100 width=96) (actual rows=100 loops=1)
123+
Filter: (coverage <> '0/'::smoc)
124+
Rows Removed by Filter: 1
125+
Buffers: shared hit=59
126+
(4 rows)
127+
88128
SET enable_seqscan = off;
89129
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
90130
SELECT * FROM moc100 WHERE coverage && '4/0';
@@ -127,6 +167,20 @@ EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
127167
Buffers: shared hit=9
128168
(8 rows)
129169

170+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
171+
SELECT * FROM moc100 WHERE coverage = '0/0-11';
172+
QUERY PLAN
173+
---------------------------------------------------------------------------------------------------------------
174+
Bitmap Heap Scan on moc100 (cost=98308.01..98312.02 rows=1 width=96) (actual rows=23 loops=1)
175+
Recheck Cond: (coverage = '0/0-11'::smoc)
176+
Rows Removed by Index Recheck: 1
177+
Heap Blocks: exact=2
178+
Buffers: shared hit=24581
179+
-> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98308.01 rows=1 width=0) (actual rows=24 loops=1)
180+
Index Cond: (coverage = '0/0-11'::smoc)
181+
Buffers: shared hit=24577
182+
(8 rows)
183+
130184
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
131185
SELECT * FROM moc100 WHERE coverage = '6/43225,43227';
132186
QUERY PLAN
@@ -154,3 +208,45 @@ EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
154208
Buffers: shared hit=4
155209
(7 rows)
156210

211+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
212+
SELECT * FROM moc100 WHERE coverage <> '0/0-11';
213+
QUERY PLAN
214+
------------------------------------------------------------------------------------------------------------------
215+
Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=78 loops=1)
216+
Recheck Cond: (coverage <> '0/0-11'::smoc)
217+
Rows Removed by Index Recheck: 23
218+
Heap Blocks: exact=5
219+
Buffers: shared hit=24821
220+
-> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1)
221+
Index Cond: (coverage <> '0/0-11'::smoc)
222+
Buffers: shared hit=24762
223+
(8 rows)
224+
225+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
226+
SELECT * FROM moc100 WHERE coverage <> '6/43225,43227';
227+
QUERY PLAN
228+
------------------------------------------------------------------------------------------------------------------
229+
Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1)
230+
Recheck Cond: (coverage <> '6/43225 43227'::smoc)
231+
Rows Removed by Index Recheck: 1
232+
Heap Blocks: exact=5
233+
Buffers: shared hit=247
234+
-> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1)
235+
Index Cond: (coverage <> '6/43225 43227'::smoc)
236+
Buffers: shared hit=188
237+
(8 rows)
238+
239+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
240+
SELECT * FROM moc100 WHERE coverage <> '0/';
241+
QUERY PLAN
242+
------------------------------------------------------------------------------------------------------------------
243+
Bitmap Heap Scan on moc100 (cost=98316.77..98323.02 rows=100 width=96) (actual rows=100 loops=1)
244+
Recheck Cond: (coverage <> '0/'::smoc)
245+
Rows Removed by Index Recheck: 1
246+
Heap Blocks: exact=5
247+
Buffers: shared hit=245
248+
-> Bitmap Index Scan on moc100_coverage_idx (cost=0.00..98316.75 rows=100 width=0) (actual rows=101 loops=1)
249+
Index Cond: (coverage <> '0/'::smoc)
250+
Buffers: shared hit=186
251+
(8 rows)
252+

‎moc.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,8 @@ smoc_gin_extract_query(PG_FUNCTION_ARGS)
11171117

11181118
if (st==MOC_GIN_STRATEGY_SUBSET|| (st==MOC_GIN_STRATEGY_EQUAL&&moc_a->area==0))
11191119
*searchmode=GIN_SEARCH_MODE_INCLUDE_EMPTY;
1120+
elseif (st==MOC_GIN_STRATEGY_UNEQUAL)
1121+
*searchmode=GIN_SEARCH_MODE_ALL;
11201122

11211123
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a,nkeys,MOC_GIN_ORDER));
11221124
}
@@ -1131,6 +1133,8 @@ smoc_gin_extract_query_fine(PG_FUNCTION_ARGS)
11311133

11321134
if (st==MOC_GIN_STRATEGY_SUBSET|| (st==MOC_GIN_STRATEGY_EQUAL&&moc_a->area==0))
11331135
*searchmode=GIN_SEARCH_MODE_INCLUDE_EMPTY;
1136+
elseif (st==MOC_GIN_STRATEGY_UNEQUAL)
1137+
*searchmode=GIN_SEARCH_MODE_ALL;
11341138

11351139
PG_RETURN_DATUM(smoc_gin_extract_internal(moc_a,nkeys,MOC_GIN_ORDER_FINE));
11361140
}
@@ -1177,6 +1181,20 @@ smoc_gin_consistent(PG_FUNCTION_ARGS)
11771181
*recheck= true;
11781182
PG_RETURN_BOOL(true);
11791183

1184+
caseMOC_GIN_STRATEGY_UNEQUAL:
1185+
/* return true when there is a difference */
1186+
for (inti=0;i<nkeys;i++)
1187+
{
1188+
if (!check[i])
1189+
{
1190+
PG_RETURN_BOOL(true);
1191+
}
1192+
}
1193+
1194+
/* we still need to recheck otherwise */
1195+
*recheck= true;
1196+
PG_RETURN_BOOL(true);
1197+
11801198
default:
11811199
Assert(0);
11821200
}

‎pgs_moc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,6 @@ next_interval(int32 a)
128128
#defineMOC_GIN_STRATEGY_SUBSET2
129129
#defineMOC_GIN_STRATEGY_SUPERSET3
130130
#defineMOC_GIN_STRATEGY_EQUAL4
131+
#defineMOC_GIN_STRATEGY_UNEQUAL5
131132

132133
#endif

‎pgs_moc_ops.sql.in‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ CREATE OPERATOR CLASS smoc_gin_ops
347347
OPERATOR 2 <@,
348348
OPERATOR 3 @>,
349349
OPERATOR 4 =,
350+
OPERATOR 5 <>,
350351
FUNCTION 1 btint4cmp (int4, int4),
351352
FUNCTION 2 smoc_gin_extract_value (smoc, internal, internal),
352353
FUNCTION 3 smoc_gin_extract_query (smoc, internal, int2, internal, internal, internal, internal),
@@ -361,6 +362,7 @@ CREATE OPERATOR CLASS smoc_gin_ops_fine
361362
OPERATOR 2 <@,
362363
OPERATOR 3 @>,
363364
OPERATOR 4 =,
365+
OPERATOR 5 <>,
364366
FUNCTION 1 btint4cmp (int4, int4),
365367
FUNCTION 2 smoc_gin_extract_value_fine (smoc, internal, internal),
366368
FUNCTION 3 smoc_gin_extract_query_fine (smoc, internal, int2, internal, internal, internal, internal),

‎sql/moc100.sql‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,24 @@ EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
118118
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
119119
SELECT*FROM moc100WHERE coverage &&'4/0';
120120

121+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
122+
SELECT*FROM moc100WHERE coverage='0/0-11';
123+
121124
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
122125
SELECT*FROM moc100WHERE coverage='6/43225,43227';
123126

124127
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
125128
SELECT*FROM moc100WHERE coverage='0/';
126129

130+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
131+
SELECT*FROM moc100WHERE coverage<>'0/0-11';
132+
133+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
134+
SELECT*FROM moc100WHERE coverage<>'6/43225,43227';
135+
136+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
137+
SELECT*FROM moc100WHERE coverage<>'0/';
138+
127139
SET enable_seqscan= off;
128140

129141
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
@@ -135,8 +147,20 @@ EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
135147
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
136148
SELECT*FROM moc100WHERE coverage @>'4/0';
137149

150+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
151+
SELECT*FROM moc100WHERE coverage='0/0-11';
152+
138153
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
139154
SELECT*FROM moc100WHERE coverage='6/43225,43227';
140155

141156
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
142157
SELECT*FROM moc100WHERE coverage='0/';
158+
159+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
160+
SELECT*FROM moc100WHERE coverage<>'0/0-11';
161+
162+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
163+
SELECT*FROM moc100WHERE coverage<>'6/43225,43227';
164+
165+
EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF)
166+
SELECT*FROM moc100WHERE coverage<>'0/';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp