Skip to main content
Version: 1.1 (Latest)

PostgreSQL

The pg_fasttransfer extension allows you to run the FastTransfer tool directly from an SQL function, enabling fast data transfer between databases directly from PostgreSQL.

Extension Overview​

ItemValue
Repositoryarpe-io/pg_fasttransfer
LicenseMIT
Latest versionv0.16.0
PlatformsLinux (Debian/Ubuntu) and Windows

pg_fasttransfer Demo

Features​

  • Native PostgreSQL IntegrationExecute FastTransfer commands directly from SQL
  • Secure Password ManagementBuilt-in encryption for sensitive credentials
  • Detailed Result ReturnGet transfer statistics and performance metrics as SQL results
  • Cross-PlatformAvailable for both Linux and Windows environments
  • Flexible ConfigurationSupport for all FastTransfer parameters

Prerequisites​

Important

The PostgreSQL server process usually runs under the postgres user account. You must ensure that this user has the appropriate permissions to execute the FastTransfer binary and read the license file.

Compatibility​

PostgreSQL VersionWindowsLinux (Debian/Ubuntu 22.04 LTS)
PostgreSQL 18SupportedSupported
PostgreSQL 17SupportedSupported
PostgreSQL 16SupportedSupported
PostgreSQL 15Not supportedSupported
Good to know

Other distributions or PostgreSQL versions may work but have not been officially tested.

Installation​

Download the appropriate release for your PostgreSQL version and operating system from the pg_fasttransfer releases page.

Automated installation (Linux)​

The easiest way to install the extension on Linux is by using the install-linux.sh script included in the archive.

  1. Extract the contents of the archive into a folder. This folder should contain pg_fasttransfer.so, pg_fasttransfer.control, pg_fasttransfer--1.0.sql and install-linux.sh.

  2. Make the script executable:

chmod +x install-linux.sh
  1. Run the script with administrator privileges:
sudo ./install-linux.sh

The script will automatically detect your PostgreSQL installation and copy the files to the correct locations.

Manual installation

If the automated script fails or you prefer to install the files manually:

  1. Stop your PostgreSQL service:
sudo systemctl stop postgresql
  1. Locate your PostgreSQL installation directory, typically: /usr/lib/postgresql/<version>

  2. Copy the files into the appropriate directories:

sudo cp pg_fasttransfer.so /usr/lib/postgresql/<version>/lib/
sudo cp pg_fasttransfer.control pg_fasttransfer--1.0.sql /usr/share/postgresql/<version>/extension/
  1. Restart your PostgreSQL service:
sudo systemctl start postgresql

Permissions setup (Linux)​

Ensure the postgres user has proper permissions:

# Grant execute permission on the FastTransfer binary
sudo chmod +x /path/to/FastTransfer
sudo chown postgres:postgres /path/to/FastTransfer
sudo chmod 750 /path/to/FastTransfer

# Grant read permission on the license file
sudo chown postgres:postgres /path/to/license.lic
sudo chmod 640 /path/to/license.lic

SQL Setup​

After the files are in place, you need to set up the extension in your database.

Drop existing extension (if any)​

DROP EXTENSION IF EXISTS pg_fasttransfer CASCADE;

Create the extension​

CREATE EXTENSION pg_fasttransfer CASCADE;

Functions​

pg_fasttransfer_encrypt​

This function encrypts a given text string using pgp_sym_encrypt and encodes the result in base64. It is useful for storing sensitive information, such as passwords, in a secure manner within your SQL scripts.

The xp_RunFastTransfer_secure function will automatically decrypt any values passed to its --sourcepassword and --targetpassword arguments.

Syntax:

pg_fasttransfer_encrypt(text_to_encrypt text) RETURNS text

Example:

SELECT pg_fasttransfer_encrypt('MySecurePassword');
-- Returns: A base64-encoded encrypted string, e.g., "PgP...base64encodedstring=="

xp_RunFastTransfer_secure​

This is the main function to execute the FastTransfer tool. It takes various parameters to configure the data transfer operation.

Password arguments (sourcepassword, targetpassword) will be automatically decrypted.

Syntax: all parameters and the returned table
xp_RunFastTransfer_secure(
sourceconnectiontype text DEFAULT NULL,
sourceconnectstring text DEFAULT NULL,
sourcedsn text DEFAULT NULL,
sourceprovider text DEFAULT NULL,
sourceserver text DEFAULT NULL,
sourceuser text DEFAULT NULL,
sourcepassword text DEFAULT NULL,
sourcetrusted boolean DEFAULT FALSE,
sourcedatabase text DEFAULT NULL,
sourceschema text DEFAULT NULL,
sourcetable text DEFAULT NULL,
query text DEFAULT NULL,
fileinput text DEFAULT NULL,
targetconnectiontype text DEFAULT NULL,
targetconnectstring text DEFAULT NULL,
targetserver text DEFAULT NULL,
targetuser text DEFAULT NULL,
targetpassword text DEFAULT NULL,
targettrusted boolean DEFAULT FALSE,
targetdatabase text DEFAULT NULL,
targetschema text DEFAULT NULL,
targettable text DEFAULT NULL,
degree integer DEFAULT NULL,
method text DEFAULT NULL,
distributekeycolumn text DEFAULT NULL,
datadrivenquery text DEFAULT NULL,
loadmode text DEFAULT NULL,
batchsize integer DEFAULT NULL,
useworktables boolean DEFAULT FALSE,
runid text DEFAULT NULL,
settingsfile text DEFAULT NULL,
mapmethod text DEFAULT NULL,
license text DEFAULT NULL,
loglevel text DEFAULT NULL,
nobanner boolean DEFAULT NULL,
fasttransfer_path text DEFAULT NULL,
debug boolean DEFAULT FALSE
) RETURNS TABLE (
exit_code integer,
output text,
error_message text,
total_rows bigint,
total_columns integer,
transfer_time_ms bigint,
total_time_ms bigint
)

Usage Examples​

Transfer data from PostgreSQL to SQL Server using the extension:

SELECT * FROM xp_RunFastTransfer_secure(
targetconnectiontype := 'msbulk',
sourceconnectiontype := 'pgsql',
sourceserver := 'localhost:5432',
sourceuser := 'postgres',
sourcepassword := pg_fasttransfer_encrypt('MyActualPassword'),
sourcedatabase := 'tpch',
sourceschema := 'tpch_1',
sourcetable := 'orders',
targetserver := 'localhost,1433',
targetuser := 'migadmin',
targetpassword := pg_fasttransfer_encrypt('AnotherSecurePassword'),
targetdatabase := 'target_db',
targetschema := 'tpch_1',
targettable := 'orders',
loadmode := 'Truncate',
license := '/tmp/FastTransfer_linux-x64_v0.15.0/FastTransfer.lic',
loglevel := 'information',
nobanner := false,
fasttransfer_path := '/tmp/FastTransfer_linux-x64_v0.15.0',
debug := true
);

Function Return Structure​

The function returns a table with the following columns:

exit_codeinteger
The exit code of the FastTransfer process.
outputtext
The full log output from FastTransfer (if debug is TRUE).
error_messagetext
Only the lines containing ERROR from the output.
total_rowsbigint
The total number of rows transferred.
total_columnsinteger
The total number of columns transferred.
transfer_time_msbigint
Transfer time in milliseconds.
total_time_msbigint
Total execution time in milliseconds.

Debug Parameter​

The debug parameter is a boolean flag that controls whether the full FastTransfer output is returned in the output column:

debug := true

  • outputContains the entire log from FastTransfer
  • error_messageAny error lines
debug := falseDefault

  • outputAn empty string
  • error_messageStill contains any error lines

Resources​

Resources
Copyright © 2026 Architecture & Performance.