PostgreSQL Examples
Comprehensive examples for transferring data from and to PostgreSQL databases using native connectors.
Connection Types
PostgreSQL transfers support multiple connection types:
- pgsql: Standard PostgreSQL protocol for reading/writing
- pgcopy: PostgreSQL COPY protocol (fastest for bulk transfers, binary format)
PostgreSQL to MSSQL - Single-threaded Transfer
Simple transfer without parallelization using a SQL query.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--query "select * from tpch_10.orders" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders" `
--parallelmethod "None" `
--loadmode "Truncate"
PostgreSQL to MSSQL - Using Schema and Table
Transfer specifying schema and table names instead of a query.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders" `
--parallelmethod "None" `
--loadmode "Truncate" `
--loglevel "debug"
PostgreSQL to MSSQL - Parallel Transfer with DataDriven Method
Transfer using DataDriven distribution based on a calculated column.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--query "select * from tpch_10.orders" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders" `
--parallelmethod "DataDriven" `
--distributeKeyColumn "FLOOR(o_orderkey/10000000)" `
--degree 6 `
--loadmode Truncate
PostgreSQL to MSSQL - Parallel Transfer with Ctid Method
PostgreSQL-specific parallel transfer using physical row identifier (ctid).
The Ctid method is unique to PostgreSQL and uses the physical row identifier (ctid) for parallel data distribution. This is very efficient for full table transfers.
For orders table:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders" `
--parallelmethod "Ctid" `
--degree 10 `
--loadmode "Truncate"
For lineitem table:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--sourceschema "tpch_10" `
--sourcetable "lineitem" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "lineitem" `
--parallelmethod "Ctid" `
--degree 10 `
--loadmode "Truncate" `
--loglevel "debug"
PostgreSQL to MSSQL - Parallel Transfer with Random Method
Transfer using Random distribution based on a key column.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--query "select * from tpch_10.orders" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders" `
--parallelmethod "Random" `
--distributeKeyColumn "o_orderkey" `
--degree 6 `
--loadmode Truncate
PostgreSQL to MSSQL - Dynamic Degree
Use negative degree values to automatically determine parallelism.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders" `
--parallelmethod "Ctid" `
--degree -4 `
--loadmode "Truncate"
A negative degree value (e.g., -4) multiplies the absolute value by the number of CPU cores to determine the actual degree of parallelism.
PostgreSQL to MSSQL - Using Input File
Transfer using a SQL query from an external file.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourcedatabase "tpch" `
--inputfile "..\..\..\..\FastTransfert\samples\select_orders.sql" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders_2" `
--parallelmethod "Ctid" `
--degree 6 `
--loadmode "Truncate"
PostgreSQL to PostgreSQL - Using Query
Transfer between PostgreSQL databases using a query.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "pgcopy" `
--targetserver "localhost" `
--targetdatabase "tpch_import" `
--query "select * from ""tpch_10"".orders" `
--targetuser "FastUser" `
--targetpassword "FastPassword" `
--targetschema "tpch_10" `
--targettable "orders" `
--parallelmethod "None" `
--loadmode Truncate
PostgreSQL to PostgreSQL - Using Ctid Method
Transfer between PostgreSQL databases with parallel Ctid method.
- Using pgcopy (Binary COPY)
- Using pgsql (INSERT UNNEST)
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "pgcopy" `
--targetserver "localhost" `
--targetdatabase "tpch_import" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetuser "FastUser" `
--targetpassword "FastPassword" `
--targetschema "tpch_10" `
--targettable "orders" `
--parallelmethod "Ctid" `
--degree 6 `
--loadmode "Truncate"
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "pgsql" `
--targetserver "localhost" `
--targetdatabase "tpch_import" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetuser "FastUser" `
--targetpassword "FastPassword" `
--targetschema "tpch_10" `
--targettable "orders" `
--parallelmethod "Ctid" `
--degree 10 `
--loadmode "Truncate" `
--batchsize 10000
PostgreSQL to PostgreSQL - Using pgcopy Binary
High-performance transfer using PostgreSQL binary COPY protocol.
Single-threaded:
.\FastTransfer.exe `
--sourceconnectiontype "pgcopy" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "pgcopy" `
--targetserver "localhost" `
--targetdatabase "tpch_import" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetuser "FastUser" `
--targetpassword "FastPassword" `
--targetschema "tpch_10" `
--targettable "orders" `
--parallelmethod "None" `
--loadmode "Truncate"
Parallel with Ctid - orders table:
.\FastTransfer.exe `
--sourceconnectiontype "pgcopy" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "pgcopy" `
--targetserver "localhost:15432" `
--targetdatabase "tpch_import" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetuser "FastUser" `
--targetpassword "FastPassword" `
--targetschema "tpch_10" `
--targettable "orders" `
--parallelmethod "Ctid" `
--degree 10 `
--loadmode "Truncate"
Parallel with Ctid - lineitem table:
.\FastTransfer.exe `
--sourceconnectiontype "pgcopy" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "pgcopy" `
--targetserver "localhost" `
--targetdatabase "tpch_import" `
--sourceschema "tpch_10" `
--sourcetable "lineitem" `
--targetuser "FastUser" `
--targetpassword "FastPassword" `
--targetschema "tpch_10" `
--targettable "lineitem" `
--parallelmethod "Ctid" `
--degree 10 `
--loadmode "Truncate"
PostgreSQL to Oracle
Transfer data from PostgreSQL to Oracle databases.
- Using orabulk (Bulk Load)
- Using oradirect (Direct Path)
Without parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "orabulk" `
--targetserver "localhost:1521/ORCLPDB" `
--targetdatabase "ORCLPDB" `
--query "select * from tpch_10.orders" `
--targetuser "TPCH_IN" `
--targetpassword "TPCH_IN" `
--targetschema "TPCH_IN" `
--targettable "ORDERS" `
--parallelmethod "None" `
--loadmode "Truncate" `
--batchsize 100000
With Ctid parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "orabulk" `
--targetserver "localhost:1521/ORCLPDB" `
--targetdatabase "ORCLPDB" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetuser "TPCH_IN" `
--targetpassword "TPCH_IN" `
--targetschema "TPCH_IN" `
--targettable "ORDERS" `
--parallelmethod "Ctid" `
--degree 12 `
--loadmode "Truncate" `
--batchsize 100000
Without parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "oradirect" `
--targetserver "localhost:1521/ORCLPDB" `
--targetdatabase "ORCLPDB" `
--query "select * from tpch_10.orders limit 10005" `
--targetuser "TPCH_IN" `
--targetpassword "TPCH_IN" `
--targetschema "TPCH_IN" `
--targettable "ORDERS" `
--parallelmethod "None" `
--loadmode "Truncate" `
--batchsize 1000
With Ctid parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "oradirect" `
--targetserver "localhost:1521/ORCLPDB" `
--targetdatabase "ORCLPDB" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetuser "TPCH_IN" `
--targetpassword "TPCH_IN" `
--targetschema "TPCH_IN" `
--targettable "ORDERS" `
--parallelmethod "Ctid" `
--degree 10 `
--loadmode "Truncate" `
--batchsize 10000
With DataDriven method:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:5432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--targetconnectiontype "oradirect" `
--targetserver "localhost:1521/ORCLPDB" `
--targetdatabase "ORCLPDB" `
--query "select * from tpch_10.orders" `
--targetuser "TPCH_IN" `
--targetpassword "TPCH_IN" `
--targetschema "TPCH_IN" `
--targettable "ORDERS" `
--parallelmethod "DataDriven" `
--distributeKeyColumn "(EXTRACT('Year' FROM o_orderdate))" `
--degree 7 `
--loadmode "Truncate" `
--batchsize 10000
PostgreSQL to SAP HANA
Transfer data from PostgreSQL to SAP HANA.
Without parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "hanabulk" `
--targetserver "hxehost:39015" `
--targetdatabase "" `
--targetuser "SYSTEM" `
--targetpassword "YourPassword" `
--targetschema "TPCH" `
--targettable "ORDERS" `
--parallelmethod "None" `
--loadmode "Truncate" `
--batchsize 5000 `
--query "select * from tpch_10.orders limit 100000"
With Ctid parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "hanabulk" `
--targetserver "hxehost:39015" `
--targetdatabase "" `
--targetuser "SYSTEM" `
--targetpassword "YourPassword" `
--targetschema "TPCH" `
--targettable "ORDERS" `
--parallelmethod "Ctid" `
--degree 4 `
--loadmode "Truncate" `
--batchsize 5000
PostgreSQL to ClickHouse
Transfer data from PostgreSQL to ClickHouse.
Without parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourceschema "tpch_10" `
--query "select * from tpch_10.orders limit 100000" `
--targetconnectiontype "clickhousebulk" `
--targetserver "localhost:8123" `
--targetdatabase "default" `
--targetuser "default" `
--targetpassword "YourPassword" `
--targetschema "default" `
--targettable "orders" `
--parallelmethod "None" `
--loadmode "Append" `
--batchsize 10000
With Ctid parallelization:
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "clickhousebulk" `
--targetserver "localhost:8123" `
--targetdatabase "default" `
--targetuser "default" `
--targetpassword "YourPassword" `
--targetschema "default" `
--targettable "orders" `
--parallelmethod "Ctid" `
--degree 15 `
--loadmode "Truncate" `
--batchsize 1000000
PostgreSQL to Teradata
Transfer data from PostgreSQL to Teradata.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:15432" `
--sourcedatabase "tpch" `
--sourceuser "FastUser" `
--sourcepassword "FastPassword" `
--sourceschema "tpch_10" `
--sourcetable "orders" `
--targetconnectiontype "teradata" `
--targetserver "192.168.239.129:1025" `
--targetdatabase "TPCH" `
--targetuser "UTPCH" `
--targetpassword "UTPCH" `
--targetschema "TPCH" `
--targettable "orders" `
--parallelmethod "Ctid" `
--degree 15 `
--loadmode "Truncate" `
--batchsize 10000
PostgreSQL (Hyper File) to MSSQL
Transfer data from a Tableau Hyper file (using pgsql driver) to MSSQL.
.\FastTransfer.exe `
--sourceconnectiontype "pgsql" `
--sourceserver "localhost:8095" `
--sourcedatabase "D:\OpenData\TPCH\data\hyper\tpch_sf10.hyper" `
--sourceuser "tableau_internal_user" `
--sourcepassword "" `
--targetconnectiontype "msbulk" `
--targetserver "localhost" `
--targetdatabase "tpch_test" `
--query "select * from ""ORDERS""" `
--targettrusted `
--targetschema "dbo" `
--targettable "orders" `
--parallelmethod "None"
Build your command with the Wizard