scribase
Data typesversion 1.5

intarray

Functions and indexes for integer arrays.

What it is for

intarray adds fast operators and index classes for int[] columns (overlap, contains, contained by) plus helpers such as sort, uniq and idx. A common use is tag or permission id lists stored on the row.

Enable it

sql
create extension if not exists intarray with schema extensions;

Example

sql
create index posts_tag_ids on posts using gin (tag_ids gin__int_ops);

select id from posts where tag_ids && array[3, 7];
select sort(uniq(sort(array[5, 3, 5, 1])));   -- {1,3,5}

Questions

How do I enable intarray?

Run create extension if not exists intarray with schema extensions; in the SQL editor, or switch it on from the Extensions page in the console. You do not need superuser access.

Which version of intarray is installed?

1.5, on Postgres 17.6, as read from the running engine on 2026-10-08. Check yours with: select extversion from pg_extension where extname = 'intarray';

Upstream project: www.postgresql.org/docs/17/intarray.html

More data types extensions

  • uuid-ossp UUID generators (v1 to v5).
  • pg_uuidv7 Time-ordered UUID v7 values.
  • citext Case-insensitive text, for emails and user names.
  • hstore Key-value pairs in one column.
  • ltree Tree paths such as categories and org charts.
  • cube Multi-dimensional points and boxes.