Test and validate
To verify that your connections and configuration work properly, run MOLT Fetch in a staging environment before migrating any data in production. Use a test or development environment that closely resembles production.Configure the source database and connection
-
To prevent connections from terminating prematurely during the data export phase, set the following to high values on the source database:
-
Maximum allowed number of connections. MOLT Fetch can export data across multiple connections. The number of connections it will create is the number of shards (
--export-concurrency) multiplied by the number of tables (--table-concurrency) being exported concurrently.With the default numerical range sharding, only tables with primary key types ofINT,FLOAT, orUUIDcan be sharded. PostgreSQL users can enable--use-stats-based-shardingto use statistics-based sharding for tables with primary keys of any data type. For details, refer to Table sharding. - Maximum lifetime of a connection.
-
Maximum allowed number of connections. MOLT Fetch can export data across multiple connections. The number of connections it will create is the number of shards (
-
If a PostgreSQL database is set as a source, ensure that
idle_in_transaction_session_timeouton PostgreSQL is either disabled or set to a value longer than the duration of the data export phase. Otherwise, the connection will be prematurely terminated. To estimate the time needed to export the PostgreSQL tables, you can perform a dry run and sum the value ofmolt_fetch_table_export_duration_msfor all exported tables.
Memory requirements
-
MOLT Fetch buffers data in memory before flushing to files or the target database, regardless of which data path you use. To prevent memory outages during data export, estimate the amount of memory used to export tables:
If you are exporting multiple tables concurrently (i.e.,
--table-concurrencyis set higher than1), estimate the memory requirement using the table with the largest average row size. For details on how concurrency and sharding interact, refer to Table sharding. Insufficient memory can cause degraded throughput, process crashes, or migration failures. To prevent memory issues:- Allocate enough memory for MOLT Fetch, based on the preceding formula.
- Adjust
--row-batch-size,--export-concurrency, or--table-concurrencyif memory is constrained. - Monitor memory utilization during the migration.
Optimize performance
-
To optimize data load performance, drop all non-
PRIMARY KEYconstraints and indexes on the target CockroachDB database before migrating:FOREIGN KEYUNIQUE- Secondary indexes
CHECKDEFAULTNOT NULL(you do not need to drop this constraint when usingdrop-on-target-and-recreatefor table handling)
You can recreate constraints and indexes after loading the data.Do not dropPRIMARY KEYconstraints. -
For PostgreSQL sources using
--use-stats-based-sharding, runANALYZEon source tables before migration to ensure optimal shard distribution. This is especially important for large tables where even distribution can significantly improve export performance. -
If a table in the source database is much larger than the other tables, filter and export the largest table in its own
molt fetchtask. Repeat this for each of the largest tables. Then export the remaining tables in another task. -
Ensure that the machine running MOLT Fetch is equipped to handle the amount of data being migrated. Fetch performance can sometimes be limited by available resources, but should always be making progress. To identify possible resource constraints, observe the
molt_fetch_rows_exportedmetric for decreases in the number of rows being processed. You can use the sample Grafana dashboard to view metrics. For details on optimizing export performance through sharding, refer to Table sharding.
Docker performance
MOLT Fetch is likely to run more slowly in a Docker container than on a local machine. To improve performance, increase the memory or compute resources, or both, on your Docker container.Import and continuation handling
- When using
IMPORT INTOduring the data import phase to load tables into CockroachDB, if the fetch task terminates before the import job completes, the hanging import job on the target database will keep the table offline. To make this table accessible again, manually resume or cancel the job. Then resumemolt fetchusing continuation, or restart the task from the beginning.
Security
Cockroach Labs strongly recommends the following security practices.Connection security
-
To keep your database credentials out of shell history and logs, follow these best practices when specifying your source and target connection strings:
- Avoid plaintext connection strings.
-
Provide your connection strings in the
MOLT_SOURCEandMOLT_TARGETenvironment variables, which MOLT Fetch and MOLT Verify read in place of--sourceand--target. For Oracle multitenant sources,MOLT_SOURCE_CDBreplaces--source-cdb. For example:Afterward, omit--sourceand--targetfrom MOLT commands. Unlike connection strings passed as flags, the environment variables do not appear in the process list. If you set both a flag and its environment variable, the flag takes precedence. - If possible, use an external secrets manager to load the environment variables from stored secrets.
-
Use TLS-enabled connection strings to encrypt data in transit from MOLT to the database. When using TLS certificates, ensure certificate files are accessible to the MOLT binary on the same machine.
For example, a PostgreSQL connection string with TLS certificates:
MySQL source connection strings use the MySQL names for TLS parameters:
ssl-mode(DISABLED,PREFERRED,REQUIRED,VERIFY_CA, orVERIFY_IDENTITY),ssl-ca,ssl-cert, andssl-key. MOLT rejects the PostgreSQL names (sslmode,sslrootcert,sslcert, andsslkey) in a MySQL connection string. For example, a MySQL connection string with TLS certificates: -
URL-encode connection strings for the source database and CockroachDB so special characters in passwords are handled correctly.
-
Given a password
a$52&, pass it to themolt escape-passwordcommand with single quotes:Use the encoded password in your connection string. For example:
-
Given a password
-
Remove
sslmode=disablefrom production connection strings.
By default, insecure connections (i.e.,
sslmode=disable on PostgreSQL; ssl-mode not set or ssl-mode=DISABLED on MySQL) are disallowed. When using an insecure connection, molt fetch returns an error. To override this check, you can enable the --allow-tls-mode-disable flag. Do this only when testing, or if a secure SSL/TLS connection to the source or target database is not possible.Connect to Oracle over TLS (TCPS)
By default, connections to Oracle use plain TCP with a standard connection string, and no wallet is needed. TLS-encrypted connections to Oracle use the TCPS protocol and require an Oracle wallet. A wallet is recommended for production deployments and required when the Oracle database listener accepts only TCPS connections. The wallet directory must contain the following three files:tnsnames.ora must define a TCPS alias. The alias name (in this example, MY_ORACLE_TLS) must match the @{alias} in your connection string:
sqlnet.ora must point the Oracle client at the wallet directory:
- A TNS alias is required. The
oracle://{host}:{port}/{service_name}URL form uses plain-TCP EZCONNECT and fails against a TCPS listener withORA-12537: TNS:connection closed. Always connect via the@{alias}defined intnsnames.ora. - Auto-login wallets only. The Oracle client driver has no wallet-password option, so use an auto-login wallet (
cwallet.sso). Because the wallet contains credentials, store it in a directory that only the user running the tool can read. - Oracle Instant Client
basicvariant required. TLS requires the fullbasicclient;basiclitemay be missing the required TLS libraries.
--source-oracle-wallet-location. For Oracle Multitenant databases, a single wallet location applies to both --source (PDB) and --source-cdb (CDB); define TCPS aliases for both endpoints in the wallet’s tnsnames.ora.
For example, to load data from an Oracle database over TCPS, connect via the TNS alias and pass the wallet directory:
Cloud storage security
Ensure that access control is properly configured for Amazon S3, Google Cloud Storage, or Azure Blob Storage.- S3
- GCS
- Azure
Amazon S3
-
Set the following environment variables in the terminal running
molt fetch:-
To run
molt fetchin a containerized environment (e.g., Docker), pass the required environment variables using-e. If your authentication method relies on local credential files, you may also need to volume map the host path to the appropriate location inside the container using-v. For example:
-
To run
-
Alternatively, set
--use-implicit-authto use implicit authentication. When using assume role authentication, specify the service account with--assume-role. For example: -
Set
--import-regionto specify anAWS_REGION(e.g.,--import-region 'ap-south-1'). -
By default, MOLT Fetch does not get credentials from the AWS EC2 instance metadata service (IMDS). This prevents long delays on hosts outside AWS. If you run MOLT Fetch on EC2 and use the instance profile for credentials, set
AWS_EC2_METADATA_DISABLED=false. Other credential sources, such as environment variables and the shared credentials file, are not affected. - Ensure the S3 bucket is created and accessible by authorized roles and users only.

