Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 20e7e1f

Browse files
committed
Remove <@ from contrib/intarray's GiST operator classes.
Since commit efc77cf, an indexed query using <@ has required a full-index scan, so that it actually performs worse than a plain seqscan would do. As I noted at the time, we'd be better off to not treat <@ as being indexable by such indexes at all; and that's what this patch does. It would have been difficult to remove these opclass members without dropping the whole opclass before commit 9f96827 fixed GiST opclass member dependency rules, but now it's quite simple, so let's do it. I left the existing support code in place for the time being, with comments noting it's now unreachable. At some point, perhaps we should remove that code in favor of throwing an error telling people to upgrade the extension version. Discussion: https://postgr.es/m/2176979.1596389859@sss.pgh.pa.us Discussion: https://postgr.es/m/458.1565114141@sss.pgh.pa.us
1 parent 39132b7 commit 20e7e1f

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

contrib/intarray/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ OBJS = \
1212
_intbig_gist.o
1313

1414
EXTENSION = intarray
15-
DATA = intarray--1.2--1.3.sql intarray--1.2.sql intarray--1.1--1.2.sql \
15+
DATA = intarray--1.3--1.4.sql intarray--1.2--1.3.sql \
16+
intarray--1.2.sql intarray--1.1--1.2.sql \
1617
intarray--1.0--1.1.sql
1718
PGFILEDESC = "intarray - functions and operators for arrays of integers"
1819

contrib/intarray/_int_gist.c

+6
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ g_int_consistent(PG_FUNCTION_ARGS)
9393
break;
9494
case RTContainedByStrategyNumber:
9595
case RTOldContainedByStrategyNumber:
96+
97+
/*
98+
* This code is unreachable as of intarray 1.4, because the <@
99+
* operator has been removed from the opclass. We keep it for now
100+
* to support older versions of the SQL definitions.
101+
*/
96102
if (GIST_LEAF(entry))
97103
retval = inner_int_contains(query,
98104
(ArrayType *) DatumGetPointer(entry->key));

contrib/intarray/_intbig_gist.c

+6
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
533533
break;
534534
case RTContainedByStrategyNumber:
535535
case RTOldContainedByStrategyNumber:
536+
537+
/*
538+
* This code is unreachable as of intarray 1.4, because the <@
539+
* operator has been removed from the opclass. We keep it for now
540+
* to support older versions of the SQL definitions.
541+
*/
536542
if (GIST_LEAF(entry))
537543
{
538544
int i,
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* contrib/intarray/intarray--1.3--1.4.sql */
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use "ALTER EXTENSION intarray UPDATE TO '1.4'" to load this file. \quit
5+
6+
-- Remove <@ from the GiST opclasses, as it's not usefully indexable
7+
-- due to mishandling of empty arrays. (It's OK in GIN.)
8+
9+
ALTER OPERATOR FAMILY gist__int_ops USING gist
10+
DROP OPERATOR 8 (_int4, _int4);
11+
12+
ALTER OPERATOR FAMILY gist__intbig_ops USING gist
13+
DROP OPERATOR 8 (_int4, _int4);
14+
15+
-- Likewise for the old spelling ~.
16+
17+
ALTER OPERATOR FAMILY gist__int_ops USING gist
18+
DROP OPERATOR 14 (_int4, _int4);
19+
20+
ALTER OPERATOR FAMILY gist__intbig_ops USING gist
21+
DROP OPERATOR 14 (_int4, _int4);

contrib/intarray/intarray.control

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# intarray extension
22
comment = 'functions, operators, and index support for 1-D arrays of integers'
3-
default_version = '1.3'
3+
default_version = '1.4'
44
module_pathname = '$libdir/_int'
55
relocatable = true
66
trusted = true

doc/src/sgml/intarray.sgml

+3-2
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@
399399

400400
<para>
401401
<filename>intarray</filename> provides index support for the
402-
<literal>&amp;&amp;</literal>, <literal>@&gt;</literal>, <literal>&lt;@</literal>,
402+
<literal>&amp;&amp;</literal>, <literal>@&gt;</literal>,
403403
and <literal>@@</literal> operators, as well as regular array equality.
404404
</para>
405405

@@ -436,7 +436,8 @@
436436

437437
<para>
438438
There is also a non-default GIN operator class
439-
<literal>gin__int_ops</literal> supporting the same operators.
439+
<literal>gin__int_ops</literal>, which supports these operators as well
440+
as <literal>&lt;@</literal>.
440441
</para>
441442

442443
<para>

0 commit comments

Comments
 (0)