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

Commit 2a8d3d8

Browse files
committed
R-tree is dead ... long live GiST.
1 parent 645adf5 commit 2a8d3d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+212
-2953
lines changed

contrib/cube/cube.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <math.h>
1111

1212
#include "access/gist.h"
13-
#include "access/rtree.h"
13+
#include "access/skey.h"
1414
#include "lib/stringinfo.h"
1515
#include "utils/builtins.h"
1616

contrib/intarray/_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "access/gist.h"
66
#include "access/itup.h"
7-
#include "access/rtree.h"
7+
#include "access/skey.h"
88
#include "catalog/pg_type.h"
99
#include "utils/array.h"
1010
#include "utils/builtins.h"

contrib/ltree/_ltree_gist.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
#include "ltree.h"
77
#include "access/gist.h"
8-
#include "access/rtree.h"
9-
#include "access/nbtree.h"
8+
#include "access/skey.h"
109
#include "utils/array.h"
1110

1211
#include "crc32.h"

contrib/ltree/ltree_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
#include "ltree.h"
77
#include "access/gist.h"
8-
#include "access/rtree.h"
98
#include "access/nbtree.h"
9+
#include "access/skey.h"
1010
#include "utils/array.h"
1111
#include "crc32.h"
1212

contrib/pg_trgm/trgm_gist.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
#include "access/gist.h"
44
#include "access/itup.h"
5-
#include "access/rtree.h"
6-
#include "utils/elog.h"
7-
#include "utils/palloc.h"
5+
#include "access/tuptoaster.h"
6+
#include "storage/bufpage.h"
87
#include "utils/array.h"
98
#include "utils/builtins.h"
10-
#include "storage/bufpage.h"
11-
#include "access/tuptoaster.h"
129

1310
PG_FUNCTION_INFO_V1(gtrgm_in);
1411
Datum gtrgm_in(PG_FUNCTION_ARGS);

contrib/seg/seg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <float.h>
1010

1111
#include "access/gist.h"
12-
#include "access/rtree.h"
12+
#include "access/skey.h"
1313
#include "utils/builtins.h"
1414

1515
#include "segdata.h"
@@ -53,7 +53,7 @@ bool *gseg_same(SEG * b1, SEG * b2, bool *result);
5353

5454

5555
/*
56-
** R-tree suport functions
56+
** R-tree support functions
5757
*/
5858
bool seg_same(SEG * a, SEG * b);
5959
bool seg_contains_int(SEG * a, int *b);

contrib/tsearch2/gistidx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
#include "access/gist.h"
66
#include "access/itup.h"
7-
#include "access/rtree.h"
7+
#include "access/tuptoaster.h"
8+
#include "storage/bufpage.h"
89
#include "utils/array.h"
910
#include "utils/builtins.h"
10-
#include "storage/bufpage.h"
11-
#include "access/tuptoaster.h"
1211

1312
#include "tsvector.h"
1413
#include "query.h"

contrib/tsearch2/query.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515

1616
#include "access/gist.h"
1717
#include "access/itup.h"
18-
#include "access/rtree.h"
18+
#include "storage/bufpage.h"
1919
#include "utils/array.h"
2020
#include "utils/builtins.h"
21-
#include "storage/bufpage.h"
2221

2322
#include "ts_cfg.h"
2423
#include "tsvector.h"

contrib/tsearch2/rewrite.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "access/gist.h"
1111
#include "access/itup.h"
12-
#include "access/rtree.h"
1312
#include "storage/bufpage.h"
1413
#include "utils/array.h"
1514
#include "utils/builtins.h"

doc/src/sgml/backup.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.75 2005/11/04 23:13:59 petere Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.76 2005/11/07 17:36:44 tgl Exp $
33
-->
44
<chapter id="backup">
55
<title>Backup and Restore</title>
@@ -1129,8 +1129,8 @@ restore_command = 'copy /mnt/server/archivedir/%f "%p"' # Windows
11291129
<itemizedlist>
11301130
<listitem>
11311131
<para>
1132-
Operations on hash and R-tree indexes are
1133-
not presently WAL-logged, so replay will not update these index types.
1132+
Operations on hash indexes are
1133+
not presently WAL-logged, so replay will not update these indexes.
11341134
The recommended workaround is to manually <command>REINDEX</> each
11351135
such index after completing a recovery operation.
11361136
</para>

doc/src/sgml/geqo.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/geqo.sgml,v 1.33 2005/10/25 13:38:09 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/geqo.sgml,v 1.34 2005/11/07 17:36:44 tgl Exp $
33
Genetic Optimizer
44
-->
55

@@ -51,8 +51,8 @@ Genetic Optimizer
5151
caused by the support of a variety of <firstterm>join
5252
methods</firstterm> (e.g., nested loop, hash join, merge join in
5353
<productname>PostgreSQL</productname>) to process individual joins
54-
and a diversity of <firstterm>indexes</firstterm> (e.g., R-tree,
55-
B-tree, hash in <productname>PostgreSQL</productname>) as access
54+
and a diversity of <firstterm>indexes</firstterm> (e.g.,
55+
B-tree, hash, GiST in <productname>PostgreSQL</productname>) as access
5656
paths for relations.
5757
</para>
5858

doc/src/sgml/gist.sgml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/gist.sgml,v 1.24 2005/11/04 23:14:00 petere Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/gist.sgml,v 1.25 2005/11/07 17:36:44 tgl Exp $
33
-->
44

55
<chapter id="GiST">
66
<title>GiST Indexes</title>
77

8-
<sect1 id="gist-intro">
9-
<title>Introduction</title>
10-
11-
<para>
128
<indexterm>
139
<primary>index</primary>
1410
<secondary>GiST</secondary>
1511
</indexterm>
16-
<indexterm>
17-
<primary>GiST</primary>
18-
<see>index</see>
19-
</indexterm>
12+
13+
<sect1 id="gist-intro">
14+
<title>Introduction</title>
15+
16+
<para>
2017
<acronym>GiST</acronym> stands for Generalized Search Tree. It is a
2118
balanced, tree-structured access method, that acts as a base template in
22-
which to implement arbitrary indexing schemes. B+-trees, R-trees and many
19+
which to implement arbitrary indexing schemes. B-trees, R-trees and many
2320
other indexing schemes can be implemented in <acronym>GiST</acronym>.
2421
</para>
2522

@@ -60,17 +57,17 @@ $PostgreSQL: pgsql/doc/src/sgml/gist.sgml,v 1.24 2005/11/04 23:14:00 petere Exp
6057
<para>
6158
This extensibility should not be confused with the extensibility of the
6259
other standard search trees in terms of the data they can handle. For
63-
example, <productname>PostgreSQL</productname> supports extensible B+-trees
64-
and R-trees. That means that you can use
65-
<productname>PostgreSQL</productname> to build a B+-tree or R-tree over any
66-
data type you want. But B+-trees only support range predicates
60+
example, <productname>PostgreSQL</productname> supports extensible B-trees
61+
and hash indexes. That means that you can use
62+
<productname>PostgreSQL</productname> to build a B-tree or hash over any
63+
data type you want. But B-trees only support range predicates
6764
(<literal>&lt;</literal>, <literal>=</literal>, <literal>&gt;</literal>),
68-
and R-trees only support n-D range queries (contains, contained, equals).
65+
and hash indexes only support equality queries.
6966
</para>
7067

7168
<para>
7269
So if you index, say, an image collection with a
73-
<productname>PostgreSQL</productname> B+-tree, you can only issue queries
70+
<productname>PostgreSQL</productname> B-tree, you can only issue queries
7471
such as <quote>is imagex equal to imagey</quote>, <quote>is imagex less
7572
than imagey</quote> and <quote>is imagex greater than imagey</quote>?
7673
Depending on how you define <quote>equals</quote>, <quote>less than</quote>
@@ -84,7 +81,7 @@ $PostgreSQL: pgsql/doc/src/sgml/gist.sgml,v 1.24 2005/11/04 23:14:00 petere Exp
8481
All it takes to get a <acronym>GiST</acronym> access method up and running
8582
is to implement seven user-defined methods, which define the behavior of
8683
keys in the tree. Of course these methods have to be pretty fancy to
87-
support fancy queries, but for all the standard queries (B+-trees,
84+
support fancy queries, but for all the standard queries (B-trees,
8885
R-trees, etc.) they're relatively straightforward. In short,
8986
<acronym>GiST</acronym> combines extensibility along with generality, code
9087
reuse, and a clean interface.

doc/src/sgml/indices.sgml

Lines changed: 41 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.54 2005/11/04 23:14:00 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.55 2005/11/07 17:36:44 tgl Exp $ -->
22

33
<chapter id="indexes">
44
<title id="indexes-title">Indexes</title>
@@ -104,7 +104,7 @@ CREATE INDEX test1_id_index ON test1 (id);
104104

105105
<para>
106106
<productname>PostgreSQL</productname> provides several index types:
107-
B-tree, R-tree, Hash, and GiST. Each index type uses a different
107+
B-tree, Hash, and GiST. Each index type uses a different
108108
algorithm that is best suited to different types of queries.
109109
By default, the <command>CREATE INDEX</command> command will create a
110110
B-tree index, which fits the most common situations.
@@ -152,43 +152,6 @@ CREATE INDEX test1_id_index ON test1 (id);
152152
See <xref linkend="indexes-opclass"> below.
153153
</para>
154154

155-
<para>
156-
<indexterm>
157-
<primary>index</primary>
158-
<secondary>R-tree</secondary>
159-
</indexterm>
160-
<indexterm>
161-
<primary>R-tree</primary>
162-
<see>index</see>
163-
</indexterm>
164-
R-tree indexes are suited for queries on two-dimensional spatial data.
165-
To create an R-tree index, use a command of the form
166-
<synopsis>
167-
CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> USING rtree (<replaceable>column</replaceable>);
168-
</synopsis>
169-
The <productname>PostgreSQL</productname> query planner will
170-
consider using an R-tree index whenever an indexed column is
171-
involved in a comparison using one of these operators:
172-
173-
<simplelist>
174-
<member><literal>&lt;&lt;</literal></member>
175-
<member><literal>&amp;&lt;</literal></member>
176-
<member><literal>&amp;&gt;</literal></member>
177-
<member><literal>&gt;&gt;</literal></member>
178-
<member><literal>&lt;&lt;|</literal></member>
179-
<member><literal>&amp;&lt;|</literal></member>
180-
<member><literal>|&amp;&gt;</literal></member>
181-
<member><literal>|&gt;&gt;</literal></member>
182-
<member><literal>~</literal></member>
183-
<member><literal>@</literal></member>
184-
<member><literal>~=</literal></member>
185-
<member><literal>&amp;&amp;</literal></member>
186-
</simplelist>
187-
188-
(See <xref linkend="functions-geometry"> for the meaning of
189-
these operators.)
190-
</para>
191-
192155
<para>
193156
<indexterm>
194157
<primary>index</primary>
@@ -208,18 +171,6 @@ CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable>
208171
</synopsis>
209172
</para>
210173

211-
<para>
212-
GiST indexes are not a single kind of index, but rather an infrastructure
213-
within which many different indexing strategies can be implemented.
214-
Accordingly, the particular operators with which a GiST index can be
215-
used vary depending on the indexing strategy (the <firstterm>operator
216-
class</>). The standard distribution of
217-
<productname>PostgreSQL</productname> includes GiST operator classes
218-
equivalent to the R-tree operator classes, and many other GiST operator
219-
classes are available in the <literal>contrib</> collection or as separate
220-
projects. For more information see <xref linkend="GiST">.
221-
</para>
222-
223174
<note>
224175
<para>
225176
Testing has shown <productname>PostgreSQL</productname>'s hash
@@ -230,21 +181,47 @@ CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable>
230181
after a database crash.
231182
For these reasons, hash index use is presently discouraged.
232183
</para>
184+
</note>
233185

234-
<para>
235-
Similarly, R-tree indexes do not seem to have any performance
236-
advantages compared to the equivalent operations of GiST indexes.
237-
Like hash indexes, they are not WAL-logged and may need
238-
reindexing after a database crash.
239-
</para>
186+
<para>
187+
<indexterm>
188+
<primary>index</primary>
189+
<secondary>GiST</secondary>
190+
</indexterm>
191+
<indexterm>
192+
<primary>GiST</primary>
193+
<see>index</see>
194+
</indexterm>
195+
GiST indexes are not a single kind of index, but rather an infrastructure
196+
within which many different indexing strategies can be implemented.
197+
Accordingly, the particular operators with which a GiST index can be
198+
used vary depending on the indexing strategy (the <firstterm>operator
199+
class</>). As an example, the standard distribution of
200+
<productname>PostgreSQL</productname> includes GiST operator classes
201+
for several two-dimensional geometric data types, which support indexed
202+
queries using these operators:
240203

241-
<para>
242-
While the problems with hash indexes may be fixed eventually,
243-
it is likely that the R-tree index type will be retired in a future
244-
release. Users are encouraged to migrate applications that use R-tree
245-
indexes to GiST indexes.
246-
</para>
247-
</note>
204+
<simplelist>
205+
<member><literal>&lt;&lt;</literal></member>
206+
<member><literal>&amp;&lt;</literal></member>
207+
<member><literal>&amp;&gt;</literal></member>
208+
<member><literal>&gt;&gt;</literal></member>
209+
<member><literal>&lt;&lt;|</literal></member>
210+
<member><literal>&amp;&lt;|</literal></member>
211+
<member><literal>|&amp;&gt;</literal></member>
212+
<member><literal>|&gt;&gt;</literal></member>
213+
<member><literal>~</literal></member>
214+
<member><literal>@</literal></member>
215+
<member><literal>~=</literal></member>
216+
<member><literal>&amp;&amp;</literal></member>
217+
</simplelist>
218+
219+
(See <xref linkend="functions-geometry"> for the meaning of
220+
these operators.)
221+
Many other GiST operator
222+
classes are available in the <literal>contrib</> collection or as separate
223+
projects. For more information see <xref linkend="GiST">.
224+
</para>
248225
</sect1>
249226

250227

doc/src/sgml/mvcc.sgml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/mvcc.sgml,v 2.52 2005/10/21 01:41:28 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/mvcc.sgml,v 2.53 2005/11/07 17:36:44 tgl Exp $
33
-->
44

55
<chapter id="mvcc">
@@ -991,18 +991,6 @@ UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 22222;
991991
</para>
992992
</listitem>
993993
</varlistentry>
994-
995-
<varlistentry>
996-
<term>
997-
R-tree indexes
998-
</term>
999-
<listitem>
1000-
<para>
1001-
Share/exclusive index-level locks are used for read/write access.
1002-
Locks are released after the entire command is done.
1003-
</para>
1004-
</listitem>
1005-
</varlistentry>
1006994
</variablelist>
1007995
</para>
1008996

@@ -1012,8 +1000,7 @@ UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 22222;
10121000
indexes, they are the recommended index type for concurrent
10131001
applications that need to index scalar data. When dealing with
10141002
non-scalar data, B-trees are not useful, and GiST indexes should
1015-
be used instead. R-tree indexes are deprecated and are likely
1016-
to disappear entirely in a future release.
1003+
be used instead.
10171004
</para>
10181005
</sect1>
10191006
</chapter>

0 commit comments

Comments
 (0)