collection
Memory optimized data type to be used inside of plpglsql func
Repository
aws/pgcollection
https://github.com/aws/pgcollection
Source
pgcollection-2.0.0.tar.gz
pgcollection-2.0.0.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgcollection | 2.0.0 | TYPE | Apache-2.0 | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3690 | collection | No | Yes | No | Yes | No | Yes | - |
| Related | pgbson intarray hstore arraymath pgjq jsquery pg_jsonschema jsonschema floatvec pg_projection |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.0.0 | 1817161514 | pgcollection | - |
| RPM | PIGSTY | 2.0.0 | 1817161514 | pgcollection_$v | - |
| DEB | PIGSTY | 2.0.0 | 1817161514 | postgresql-$v-collection | - |
Build
You can build the RPM / DEB packages for pgcollection using pig build:
Install
You can install pgcollection directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Install
pig
dnf
apt
Create Extension:
Usage
The collection extension provides two memory-optimized collection data types for use within PL/pgSQL functions.
Data Types
collection: Key-value pairs with text keys (max 32,767 chars), stored in creation ordericollection: Key-value pairs with 64-bit integer keys, enabling sparse arrays
Both types support type modifiers to specify element types:
Subscript Access
Core Functions
| Function | Description |
|---|---|
add(coll, key, value) | Add element |
count(coll) | Element count |
delete(coll, key) | Remove element |
exist(coll, key) | Check key existence |
find(coll, key) | Retrieve value |
first(coll) | Move iterator to start |
last(coll) | Move iterator to end |
next(coll) | Advance iterator |
prev(coll) | Reverse iterator |
key(coll) | Current key |
value(coll) | Current value |
copy(coll) | Create copy |
sort(coll) | Sort by keys |
keys_to_table(coll) | All keys as set |
values_to_table(coll) | All values as set |
to_table(coll) | Keys and values as table |
Iterator Example
Sparse Arrays (icollection)
icollection supports non-contiguous integer indices and distinguishes between NULL values and uninitialized keys:
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)