Managing Database and Table Grouping
To enhance data querying, data modification, data replication, and other requirements under a database sharding architecture, NineData provides the database and table grouping feature. This article introduces how to create and delete database and table groupings.
Creating a Database Group
Log in to the NineData Console.
In the left navigation bar, click Datasource**Datasource**.
Click the Database Grouping tab, and click Create Database Grouping Target Data Source on the page.
Configure the form according to the table below, and click Create Database Grouping.
Parameter Description Database Grouping Name Enter the name of the database group, which supports only English characters, numbers, and underscores, starting with an English character. To facilitate subsequent use and management, please try to use meaningful names. Description(Optional) Enter a business description for this database group. Environment Select the name of the environment your business belongs to, and you will filter data sources based on this environment. Database Click Add Datasource, add data sources. - Datasource: Select the data sources to be added to the group, supporting multi-select, select all, and deselect operations, and also supporting searching by entering the data source name.
- Database Expression: Enter a database expression, and the system will automatically traverse and extract all databases in the target data source that match the expression based on the expression you provide. For the syntax of the expression, please refer to the Appendix of this article.
After the database group is created, it defaults to the SQL development standards and approval processes configured in the environment it belongs to. You can change them according to your business needs.
Creating a Table Group
Log in to the NineData Console.
In the left navigation bar, click Datasource**Datasource**.
Click the Database Grouping tab, and click the name of the target database group, or click the
Details in the Actions column on the right side of the database group.
On the Database Grouping Detail page, click Create Table Grouping.
Configure the form according to the table below, and click Create Table Grouping.
Parameter Description Table Grouping Name Enter the name of the table group, which supports only English characters, numbers, and underscores, starting with an English character. To facilitate subsequent use and management, please try to use meaningful names. Methods Supports Add Manually and Add by Expression. Add by Expression Required when Methods is set to Add by Expression. Enter an expression and click Auto Fetch, the system will automatically traverse and extract all tables in the target database that meet the requirements based on the expression you provide. For the syntax of the expression, please refer to the Appendix of this article. Routing Algorithm(Optional) Configurable when Methods is set to Add by Expression. Configure this parameter based on the routing algorithm configured in your application, which can quickly resolve the tables you need to access based on the routing, improving query efficiency. Database Required when Methods is set to Add Manually. Click Add Datasource, select the data sources to be added to the group, supporting multi-select, select all, and deselect operations, and also supporting searching by entering the data source name. After clicking OK, you still need to select specific databases and tables. Depending on the data source, you may also need to select specific Schemas. tipTo quickly route to the table where the query conditions are located through Routing Algorithm and obtain the query results at the fastest speed, the following three conditions must be met simultaneously. If any of them are not met, the query will traverse all sharded databases and tables for the query.
- The table group is created by an expression, not manually selected.
- Routing Algorithm is correctly configured in the above table group creation process, and this algorithm must be consistent with the routing algorithm configured in your application.
- The WHERE condition of the query SQL, the routing field is an equality search condition.
Removing a Table Group
When you need to readjust the database and table grouping due to changes in data structure, unreasonable grouping configuration, etc., you can remove the current table group and add it again.
Log in to the NineData Console.
In the left navigation bar, click Datasource**Datasource**.
Click the Database Grouping tab, and click the name of the target database group, or click the
Details in the Actions column on the right side of the database group.
On the Database Grouping Detail page, click the Table Grouping tab, click the
Remove under the Actions column on the right side of the target table group to be removed, and then click OK.
Deleting a Database Group
Log in to the NineData Console.
In the left navigation bar, click Datasource**Datasource**.
Click the Database Grouping tab, and click the
Delete under the Actions column on the right side of the target database group to be deleted, and then click OK.
tipIf the current database group is associated with unfinished replication tasks, the database group cannot be deleted. You need to find and terminate the corresponding replication tasks and try to delete the database group again.