Cross-database queries in TiDB: querying multiple databases with results from multiple tables across these databases. Is it suitable for TiDB?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb垮库查询,即有多个库,结果来自多个库的多个表。适合适用于tidb?

| username: TiDB_New_People

TiDB cross-database queries, which involve multiple databases and results from multiple tables across these databases. Is this suitable for TiDB?
How is the query efficiency?
Are there any considerations to keep in mind?
Is there detailed documentation from the official sources?

| username: 长安是只喵 | Original post link

First, it is necessary to clarify whether it is cross-database within the same cluster or cross-database across different clusters.

Then,

Cross-database within the same cluster: In practice, there is no noticeable difference compared to querying within the same database.

Cross-database across different clusters: It is not directly supported, but it can be achieved through other means, although efficiency will definitely be affected. However, according to the dev conference, it will be supported in the future.

I haven’t seen any similar official documentation.

| username: TiDB_New_People | Original post link

Thank you.

| username: h5n1 | Original post link

Don’t mess around with cross-cluster setups. There’s a post from a guy with a single cluster having over 6000 databases and more than 500,000 tables.

| username: banana_jian | Original post link

As long as it’s within the cluster, there shouldn’t be any major issues.

| username: xuexiaogang | Original post link

Cross-database is actually just cross-schema, it’s fine.
Cross-instance, regardless of whether it is supported or not, no database can perform the same as if it were not cross-instance.

| username: cs58_dba | Original post link

It is recommended to consolidate the tables into the same database.

| username: Mark | Original post link

For cross-database performance within the same instance, you can check the cluster configuration. For cross-instance, you can aggregate relevant data on the application side or achieve it through other methods.

| username: forever | Original post link

All databases on an instance are similar to schemas in PostgreSQL, just a logical isolation.

| username: system | Original post link

This topic will be automatically closed 60 days after the last reply. No new replies are allowed.