cos_fdw
cos_fdw · TencentDB PostgreSQL foreign data wrapper for reading CSV data from Tencent Cloud Object Storage (COS).
Overview
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | pgcrypto |
Usage
Sources:
cos_fdw is a TencentDB for PostgreSQL provider extension that exposes headerless CSV files in Tencent Cloud Object Storage (COS) as read-only foreign tables. Use it for cold-data queries and migration into local tables; it is not a portable community FDW or a general object-storage writer.
Core Workflow
Export data as CSV without a header, upload it to a COS bucket in an appropriate region, and then create the dependency, wrapper, server, and foreign table. The host value is the bucket access domain without an http:// or https:// prefix.
To map several objects to one table, place comma-separated paths with no extra spaces in filepath. Use EXPLAIN to inspect the COS URL, per-file sizes, and total estimated size. Copy selected rows into a local table with INSERT INTO local_table SELECT ... FROM archive_sensor_log when local indexing or transactional writes are needed.
Options and Boundaries
- Server options include
host,bucket,id, andkey. - Table options include
filepath,format 'csv', CSV parsing options such asdelimiterandnull, and per-columnforce_not_null. - The extension reads foreign data; inserts routed to a COS foreign partition are not supported.
pgcryptois required because TencentDB encrypts the stored COS credential fields. Treatidandkeyas secrets even though catalog storage is encrypted.
Provider Operations
Availability, supported PostgreSQL versions, privileges, upgrades, and credential handling are controlled by TencentDB. Check the extension matrix for the exact instance kernel before running CREATE EXTENSION.
COS reads add network latency, request cost, and an external consistency boundary. Restrict who can create or alter foreign servers, scope COS credentials to the required bucket and paths, keep the database and bucket in suitable regions, and test malformed rows and missing objects before using a foreign table in production queries.