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
| Object | Select | Insert | Update | Delete |
|---|---|---|---|---|
| Vector Indexes | ✅ | ✅ | ✅ |
Supported Data Types
| Postgres Type | S3 Vectors Type |
|---|---|
| text | String |
| boolean | Boolean |
| smallint | Int16 |
| integer | Int32 |
| bigint | Int64 |
| real | Float32 |
| double precision | Float64 |
| jsonb | JSON object |
| s3vec | Float32 array (vector) |
Preparation
Before you get started, make sure the wrappers extension is installed on your database:
_10create extension if not exists wrappers with schema extensions;
and then create the foreign data wrapper:
_10create 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:
_11select vault.create_secret(_11 '<access key id>',_11 'vault_access_key_id',_11 'AWS access key for Wrappers'_11);_11_11select 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:
_10create 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:
_10create 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
Third-party integrations and docs are managed by Supabase partners.