TDengine Query Migration
Query migration writes data for selected TDengine objects and time ranges to another target database. It suits historical migration over a defined window and can also read continuously in query-based real-time mode. Start with one supertable and verify the structure and time boundaries before expanding. Validate cross-version compatibility for the exact version combination.
Both source and target in the minimal example are TDengine TSDB Enterprise v3.4.3.12.
Where to operate: taosExplorer → Data In → Create New Task → TDengine Query, or run taosx run on a command-line host that can reach both sides. Run preparation and verification SQL in the taosExplorer Data Browser or taos CLI.
Query migration reads source table structures and data within a specified time range, then writes them to the target. Historical mode exits on completion. Query-based real-time mode repeatedly queries time windows, unlike TMQ log subscription. For cross-version migration, first validate the exact version combination, data types, and schema statements. A successful connection does not prove database-wide compatibility.
1. Prerequisites
- Record both server versions and the taosX, taosAdapter, and client versions. For cross-version migration, migrate one representative supertable into an isolated target database before expanding to all business databases.
- Have the source administrator grant schema and data read permissions. An authorized TDengine TSDB administrator must prepare the target database and necessary schema-creation and write permissions.
- Record database precision, retention, supertable and child-table sets, historical range, and time zone. Source data to migrate must still be queryable.
- Check network access and authentication to both sides from the actual taosX execution host. WebSocket DSNs use the taosAdapter address; the example port is
6041.
Query migration does not include users, roles, permissions, or application connection configuration. If target structures already exist, compare definitions first. Do not rely on automatic rewriting to resolve every conflict.
2. Minimal Historical Migration
Have an authorized TDengine TSDB administrator prepare isolated test objects in the taosExplorer Data Browser or taos CLI. Confirm the names below are unused. If they exist, choose new names and update commands and queries consistently; do not overwrite business objects. One test cluster can use two different databases. Across clusters, create source objects at the source and the target database at the target.
CREATE DATABASE taosx_demo_src PRECISION 'ms';
CREATE DATABASE taosx_demo_dst PRECISION 'ms';
CREATE STABLE taosx_demo_src.meters
(ts TIMESTAMP, value DOUBLE) TAGS (site VARCHAR(16));
CREATE TABLE taosx_demo_src.meter_1
USING taosx_demo_src.meters TAGS ('lab');
INSERT INTO taosx_demo_src.meter_1 VALUES
('2026-11-20T00:00:00Z', 10.5)
('2026-11-20T00:00:30Z', 11.5)
('2026-11-20T00:01:00Z', 12.5);
Timestamps must fall within source and target retention. Otherwise shift all times in the sample, commands, and verification queries together, keeping the three points 30 seconds apart. Both databases use the same millisecond precision. This example migrates the first minute, so the first two rows are included and the third row at the end boundary is excluded.
The following commands are only for an exercise where source and target are in the same isolated test cluster, taosAdapter shares the command execution environment, and the default root / taosdata password is unchanged. In an actual deployment, substitute approved identities and addresses for both sides. Do not use default accounts in production.
- Linux
- Windows
Run in Bash:
taosx run -f 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_src?stables=meters&mode=history&start=2026-11-20T00:00:00Z&end=2026-11-20T00:01:00Z' -t 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_dst'
Run in PowerShell, adjusting the installation path if necessary:
& 'C:\TDengine\taosx.exe' run -f 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_src?stables=meters&mode=history&start=2026-11-20T00:00:00Z&end=2026-11-20T00:01:00Z' -t 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_dst'
This example migrates a UTC half-open interval: the start is included and the end is excluded. Expect only the two records 10.5 and 11.5, not 12.5 at the end boundary. The timestamps must fall within retention on both sides. URL-encode reserved characters in DSNs. Outer quotes prevent the shell from interpreting &. Do not paste command output containing credentials directly into tickets.
The command runs under the current account; it is not a browser task. Check the exit code with $LASTEXITCODE or $? after it ends. 127.0.0.1 refers only to the command's environment. Reconfirm actual endpoints across hosts, containers, or WSL.
3. Configure an Equivalent Task in the GUI
- Click Create New Task, select TDengine Query, enter
quickstart_queryas the name, and select target databasetaosx_demo_dst. - Under Connection Configuration, select the protocol and enter the source server, port, and database. Under Authentication, enter the source username and password, then check connectivity. Fill individual GUI fields; do not paste a complete DSN into the server field.
- Under Migration Mode, set Mode to
historyand Schema toalways. If matching target structures are prepared and the explicit schema-sync phase should be skipped, compare definitions before selectingnone. This is not a switch that prohibits all DDL. Certain missing-column errors can still trigger column addition, so it does not guarantee an unchanged target schema. - Under Tables, enter only
metersin Supertables. Under Time Range, explicitly set the one-minute start and end and record the UI time zone. Initially keep other object, sparse-mode, and metadata-polling settings unchanged; do not add complex transformations at the same time. - Add no renaming initially. Review advanced options, submit, and start. Record execution status and activity details in the list, then run the next section's queries on the target cluster. Saved configuration without task startup, or success shown in the task list, does not replace result checks.
3.1 Fill Each GUI Field
Create the task in the taosExplorer instance for the target cluster. With WS, the source server and port point to the source cluster's taosAdapter, not the browser or target taosAdapter. Use the source database and supertable above for the first exercise. Target Database is taosx_demo_dst, not the source database name.

| Configuration | First exercise | Checks before expansion |
|---|---|---|
| Protocol, server, port, database | For the same-environment exercise, select WS, server 127.0.0.1, port 6041, database taosx_demo_src. | Across hosts, use the source taosAdapter address. Check actual client dependencies for other protocols. |
| Authentication | Use root / taosdata only for the isolated exercise with unchanged credentials; use an approved source identity in production. | Confirm this identity separately from the target write account, and check source schema and data permissions. |
| Object selection | Select only meters; do not test whole-database selection and exclusion rules together. | Check whether supertables, child tables, regular tables, and empty tables are included. |
| Mode | Historical. | Historical, real-time, and historical plus real-time define different task scopes. |
| Time range | The one-minute window above, with UI time zone matching the UTC sample. | Start/end boundaries, retention, and target precision. |
| Schema | Migrate schema into an empty target database; compare first if structures exist. | Supertables, tags, child-table references, and existing data. |
| Transformations | Add none initially. | After establishing a baseline, add and verify them one at a time as described in Object Selection and Renaming. |
| Advanced options | Start with defaults and observe resources; do not increase concurrency immediately. | Source query load, write throughput, and target schema-creation duration. |
After creation, record the task name, actual execution node, object scope, and mappings. Inspect activity and runtime status in the task list. If preparation takes a long time, first check schema-creation volume, permissions, and logs. Do not hide missing objects by switching to “do not migrate schema.”
3.2 Check Mode, Objects, and Time Range

Initially select history and always. Schema migration can take time with many child tables; assess it using activity information rather than switching directly to none to skip it. Sparse mode reads multiple low-frequency child tables by supertable window; it is not a general acceleration switch. Sparse mode cannot be enabled if a direct source DSN provides only a valid tables list or provides both valid stables and tables lists. If neither list is valid, it may enumerate all supertables in the database and handle regular tables separately, rather than reject execution or read an empty set. Leave sparse mode disabled initially. When needed, explicitly provide a small stables list and verify the actual scope. Do not infer submitted lists from UI field names alone.
Enter meters from above in Supertables, leaving Tables empty initially. The gray metrics and d0001 in the image are format hints, not selected objects. Confirm actual input before submitting. Empty selections can expand to all objects; do not use an empty default configuration before reviewing the scope.
Start Time and End Time constrain historical reads. The real-time phase keeps advancing and does not stop automatically at this end time. Query Unit splits read windows; it is neither total migration duration nor a scheduled execution period. Dates in the image are input hints only. For the first run, enter the one-minute sample above and check the UI time zone. With dense source data, reduce the query unit first and observe query duration and execution-host memory. Do not cover all history in one request.
3.3 Record Advanced Settings and Error Files

In a new form, Maximum Read Concurrency starts at 0, Maximum Write Concurrency at 1, and compression is initially off. These are not defaults for every connector. Retain them initially, record source load, read duration, and target write behavior, then adjust one setting at a time. Configure WebSocket compression according to the actual link and dependencies on both sides; it does not change data scope or position semantics.
To use Error Record File, first prepare a controlled directory writable by the service account on the actual taosX execution host. Enter a file path on that host, not a browser download path. This file stores query-migration failures. Its format and reading commands differ from Logs and Performance; do not process it directly with taosx archive. Retain original errors, task scope, and related logs. Check the target by failed object. Recording errors in a file does not establish migration completeness.
Mode and schema settings have the following meanings:
| Item | Meaning and boundaries |
|---|---|
| Historical | Read the selected historical range and exit on completion; explicitly set mode=history in CLI. |
| Real-time | Continuously query new time windows; CLI uses mode=realtime. Assess lookback coverage for late data or writes with old timestamps. |
| Historical plus real-time | Read history, then query continuously. The direct DSN mode corresponding to this GUI option is mode=all; do not put the UI value both directly into a DSN. |
| Schema migration | Source DSN schema=always synchronizes schema first; schema=none skips the explicit schema phase; schema=only synchronizes only schema and returns. none requires matching precreated structures but does not guarantee zero DDL: certain missing-column errors can still trigger target column addition. The same-named target schema parameter does not replace the source schema-phase setting. |
| Continuous-query windows | Source DSN retro performs startup backfill when entering real-time mode, not a rolling lookback on every cycle. interval is the continuous-query interval; excursion leaves a margin at the current read upper bound. These are not TMQ position parameters. |
Query-based continuous reads do not automatically discover arbitrarily old late data, deletions, or every change. For such needs, assess TMQ Continuous Synchronization first. Reducing the query interval alone does not guarantee complete replication.
For example, with real-time settings interval=1s&excursion=500ms, each successful cycle continues from the completed upper time bound. Even with retro=5m, it does not requery the past five minutes every second. Records written later with earlier business timestamps may fall outside completed windows; confirm backfill ranges separately. Before using parameters, check Query Migration Window and Connection-Pool Parameters, which explains aliases, zero values, and the restriction against tuning source connection-pool parameters.
3.4 Choose the Correct CLI Parameter Direction
For source objects, times, modes, schema phases, and read work units, see Query Source Parameters. For write-concurrency, fails-to, and other options written in --from but affecting target writes or migration compatibility, see Query Source Compatibility Parameters. For the target DSN's own database-creation, write, retry, and failure-file options, see Query Target Parameters. Check same-named keys by direction. Do not apply underscore spellings from shared external-database advanced parameters; this entry point uses write-concurrency, not write_concurrency.
For a complete migration, do not control throughput with a finite limit or nonzero offset: they repeatedly limit or skip rows in every actual query window and do not automatically paginate to complete the data. To reduce load, shrink source unit first, then adjust work units and effective target write options individually against the baseline. Source DSN write-concurrency is rounded upward by work unit; it is not a strict global write-concurrency cap. Target batch-size also applies only to corresponding write paths, not as a universal memory cap for all migrations.
Save the original configuration and confirm permissions before changing schema, mappings, or error handling. Target DSN fails-to takes precedence over the same-named source DSN key and uses a file on the execution host. Some schema errors may be logged while execution continues, but this does not mean all data errors are skipped or automatically backfilled. Check target schema and data against failed objects in the file before deciding on backfill. Normal exit does not replace verification.
4. Verify Schema and Time Boundaries
Connect separately to source and target in the taosExplorer Data Browser or taos CLI and query the same objects and window:
SELECT ts, value, site FROM taosx_demo_src.meter_1
WHERE ts >= '2026-11-20T00:00:00Z' AND ts < '2026-11-20T00:01:00Z'
ORDER BY ts;
SELECT ts, value, site FROM taosx_demo_dst.meter_1 ORDER BY ts;
DESCRIBE taosx_demo_dst.meters;
Expect two target rows, both tagged lab, with a structure matching the source. Before expanding, also check other tables, empty tables, string lengths, and existing target data. See Validation and Business Cutover.
5. Troubleshooting
| Symptom | Next action |
|---|---|
| Connection or authentication failure | Check both DSNs, ports, certificates, permissions, and licenses from the actual command-line or service execution host. |
| No records migrated | Run the same object/time-range query on the source first; check retention and selection criteria. |
| Table-creation statement fails | Compare versions, types, and existing target structures. Stop scope expansion and retain the original error. |
| Continuous queries miss old-timestamp data | Check whether actual write time differs from the primary timestamp. Assess backfill and an appropriate continuous-sync solution. |
For other task, write, and runtime issues, see Troubleshooting by Symptom.
6. Stop and Resume
Stop and restart the original service task in taosExplorer, retaining the progress directory and related files. Stop a standalone foreground taosx run with Ctrl+C. After interruption, check the range already written to the target before choosing a rerun interval. Do not assume standalone taosx run automatically inherits a GUI task's checkpoint, and do not force reruns by deleting local state.
7. Limitations
Verify required client libraries, types, and schema compatibility for the exact cross-version combination. This example does not establish support for arbitrary older and newer versions. Query migration does not create a complete restorable backup or switch application connections. Production cutover requires separate validation and rollback plans.