I have use case of timeseries data, I am using Timescale DB and wanted to migrate all data from Timescale DB to TiDB. As per understanding TiDB does not support Timeseries functions by default. Could you please suggest how we can enable timeseries support on TiDB
TiDB does not have built-in support for Timeseries data, but it provides a feature called External Storage that allows you to use other storage engines to store and query Timeseries data. You can use TimescaleDB as an external storage engine for TiDB to enable Timeseries support. Here are the steps to enable Timeseries support on TiDB using TimescaleDB:
Install TimescaleDB on your system. You can follow the installation guide provided by TimescaleDB to install it.
Create a TimescaleDB database and table to store your Timeseries data. You can follow the TimescaleDB documentation to create a database and table.
Enable the External Storage feature in TiDB by setting the
tidb_enable_external_storagesystem variable to
true. You can set this variable globally or for a specific session. When this feature is enabled, TiDB can use external storage engines to store and query data.
Create an external table in TiDB that points to the TimescaleDB table you created in step 2. You can use the
CREATE EXTERNAL TABLEstatement to create an external table. Here is an example:
CREATE EXTERNAL TABLE ts_data ( time TIMESTAMP NOT NULL, value DOUBLE NOT NULL ) ENGINE 'TIMESCALEDB' CONNECTION 'host=timescaledb_host port=timescaledb_port user=timescaledb_user password=timescaledb_password dbname=timescaledb_dbname' OPTIONS ( 'timescaledb.table' 'ts_data' );
In this example,
ts_datais the name of the TimescaleDB table that stores your Timeseries data. You need to replace
timescaledb_dbnamewith the actual values for your TimescaleDB installation.
Query the external table in TiDB to retrieve your Timeseries data. You can use standard SQL queries to query the external table. Here is an example:
SELECT * FROM ts_data WHERE time >= '2022-01-01' AND time < '2022-02-01';
This query retrieves all data from the
ts_datatable in TimescaleDB that has a timestamp in January 2022.
That’s it! With these steps, you can use TimescaleDB as an external storage engine for TiDB to enable Timeseries support.
The answer from bot is not correct. TiDB don’t support Timeseries functions yet. tidb is a general purpose database, just like MySQL. So when you want to migrate data from timescaledb to TiDB, it is same with migrating to MySQL.
Can’t we use an alternate functions in TiDB for timeseries functions like time_bucket_gapfill, time_sum, time_min, time_avg, time_bucket, create_continuous_agg etc?
TiDB don’t have such functions. May I know why you want to migrate data from a time series database to TiDB?