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

Commit0f8c311

Browse files
committed
Update README. Add information about array ops.
1 parent6838aa2 commit0f8c311

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,38 @@ For type: `anyarray`
227227

228228
This operator class stores`anyarrray` elements with length of the array.
229229
Supports operators`&&`,`@>`,`<@`,`=`,`%` operators. Supports ordering by`<=>` operator.
230+
For example we have the table:
231+
232+
```sql
233+
CREATETABLEtest_array (i int2[]);
234+
235+
INSERT INTO test_arrayVALUES ('{}'), ('{0}'), ('{1,2,3,4}'), ('{1,2,3}'), ('{1,2}'), ('{1}');
236+
237+
CREATEINDEXidx_arrayON test_array USING rum (i rum_anyarray_ops);
238+
```
239+
240+
Now we can execute the query using index scan:
241+
242+
```sql
243+
SET enable_seqscan TO off;
244+
245+
EXPLAIN (COSTS OFF)SELECT*FROM test_arrayWHERE i &&'{1}'ORDER BY i<=>'{1}'ASC;
246+
QUERY PLAN
247+
------------------------------------------
248+
Index Scan using idx_arrayon test_array
249+
Index Cond: (i &&'{1}'::smallint[])
250+
Order By: (i<=>'{1}'::smallint[])
251+
(3 rows
252+
253+
SELECT*FROM test_arrayWHERE i &&'{1}'ORDER BY i<=>'{1}'ASC;
254+
i
255+
-----------
256+
{1}
257+
{1,2}
258+
{1,2,3}
259+
{1,2,3,4}
260+
(4 rows)
261+
```
230262

231263
###rum_anyarray_addon_ops
232264

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp