Back
S3 Vectors Wrapper

S3 Vectors Wrapper

Overview

S3 Vectors Wrapper

Amazon S3 Vectors is the first cloud object storage with native support for storing and querying vectors at scale. It delivers purpose-built, cost-optimized vector storage for AI agents, RAG, inference, and semantic search, supporting up to 2 billion vectors per index with sub-100ms query latency and up to 90% cost reduction compared to dedicated vector databases.

The S3 Vectors Wrapper brings your vector indexes into Postgres as queryable foreign tables. Insert, query, and delete vectors with plain SQL, perform approximate nearest neighbor (ANN) similarity search using the <=> operator, and filter results by metadata. Works with Supabase Vault for secure credential management and uses the same two-secret pattern as the S3 and Iceberg wrappers.

Supported Operations

ObjectSelectInsertUpdateDelete
Vector Indexes

Supported Data Types

Postgres TypeS3 Vectors Type
textString
booleanBoolean
smallintInt16
integerInt32
bigintInt64
realFloat32
double precisionFloat64
jsonbJSON object
s3vecFloat32 array (vector)

Preparation

Before you get started, make sure the wrappers extension is installed on your database:


_10
create extension if not exists wrappers with schema extensions;

and then create the foreign data wrapper:


_10
create foreign data wrapper s3_vectors_wrapper
_10
handler s3_vectors_fdw_handler
_10
validator s3_vectors_fdw_validator;

Secure your credentials (optional)

By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.

Store your AWS credentials as two separate secrets and use the returned key IDs in the create server command with a vault_ prefix:


_11
select vault.create_secret(
_11
'<access key id>',
_11
'vault_access_key_id',
_11
'AWS access key for Wrappers'
_11
);
_11
_11
select vault.create_secret(
_11
'<secret access key>',
_11
'vault_secret_access_key',
_11
'AWS secret access key for Wrappers'
_11
);

Connecting to S3 Vectors

We need to provide Postgres with the credentials to connect to S3 Vectors. We can do this using the create server command:

With Vault:


_10
create server s3_vectors_server
_10
foreign data wrapper s3_vectors_wrapper
_10
options (
_10
vault_access_key_id '<key_ID>',
_10
vault_secret_access_key '<secret_key>',
_10
aws_region 'us-east-1',
_10
endpoint_url 'http://localhost:8080' -- optional, for alternative S3 services
_10
);

Without Vault:


_10
create server s3_vectors_server
_10
foreign data wrapper s3_vectors_wrapper
_10
options (
_10
aws_access_key_id '<key_ID>',
_10
aws_secret_access_key '<secret_key>',
_10
aws_region 'us-east-1',
_10
endpoint_url 'http://localhost:8080' -- optional, for alternative S3 services
_10
);

About the s3vec type

The S3 Vectors Wrapper introduces a custom Postgres type, s3vec, for storing and working with high-dimensional vectors. It stores Float32 arrays and accepts JSON array input:


_10
'[0.1, 0.2, 0.3, 0.4, 0.5]'::s3vec

Use the <=> operator for approximate nearest neighbor similarity search, and s3vec_distance() to retrieve the distance score from the most recent search result.

Resources

Details

DeveloperSupabase
DocumentationLearn

Third-party integrations and docs are managed by Supabase partners.

Get started with S3 Vectors Wrapper and Supabase.