You need to enable JavaScript to run this app.
Database Workshop

Database Workshop

Copy page
Download PDF
SQL window
Index management
Copy page
Download PDF
Index management
This topic describes how to visually create, and delete indexes in the command execution window of the Database Workshop (DBW) console to achieve full lifecycle management of indexes.​
Prerequisites​
  • An instance for Document Database for MongoDB has been created and its root account password has been set. For detailed steps, see Creating an instance.​
Precautions​
  • Deleting or modifying collections in the system database is not supported.​
  • Deleting the default index _id_ in the collection is not supported.​
  • Creating or deleting an index consumes certain CPU resources. To reduce the impact of creating or deleting an index on your instance, we suggest taking the following measures:​
  • Create or delete indexes during off-peak hours.​
  • Enable the Background option to create indexes in the background, avoiding operation blocking caused by index creation.​
  • When creating or deleting indexes, the index change operations are executed serially, that is, the creation, modification, or deletion of the previous index must be completed on all nodes before proceeding to the next index creation or deletion operation.​
Create an index​
tip​
It is not recommended to create an index in the system database.​
  1. On the top menu bar of the Data interaction platform page, click the icon after Database and select the target database.​​icon after the database, select the target database.​
  1. In the visual area of the Data interaction platform, expand the Collection, right-click the index, and select Create index.​
  1. On the Create index@Database tab, configure the index parameters.​
  • ​
    Parameter​
    ​
    Description​
    Index information​
    Database​
    Displays the database name of the current index without requiring configuration.​
    ​
    Owning collection​
    Displays the collection name of the current index without requiring configuration.​
    ​
    Index name​
    Custom index name. The naming rules are as follows:​
    • The length must be within 64 characters, and can not be empty.​
    • It can contain only Chinese characters, letters, digits, underscores (_), and hyphens (-).​
    ​
    Key​
    • Create key​
    • Click Create. In the Key name column, set the name of the key. In the Sort column, set the order of the keys. The current sort supports the asc, desc, and hashed options.​
    • Delete key​
    • Check the target key and click Delete.​
    Advanced configuration​
    Background​
    Check whether to use Background to avoid blocking other operations during index creation. Checked by default.​
    ​
    Unique​
    Check the Unique option to create a unique index. If duplicate records exist, they will be rejected.​
    ​
    Sparse​
    Check whether to enable Sparse. If the field data does not exist, the index is not enabled. After selection, documents that do not include the index field can not be queried.​
    ​
    TTL​
    Check whether to enable the TTL index mode. TTL can be used to automatically delete expired documents, helping you manage and clean up time-sensitive data, ensuring that the data in the database remains current and relevant.​
    tip​
    A TTL index can only be created on a single field containing date values, and this field must be of a timestamp type, such as Timestamp. If it is a non-date field, the TTL index will not take effect. It is recommended to use the ascending order to ensure that the earliest documents are deleted. For more information on TTL, refer to Official documentation for MongoDB.​
    ​
    ExpireAfterSeconds​
    Set automatic deletion of data in the collection after a specified time to save storage space and improve query performance. The value range is [0, 2147483647], in second(s).​
    tip​
    You must configure this parameter when TTL is selected.​
    ​
  1. Click Submit.​
  1. In the Execute SQL dialog box, confirm the SQL statement for creating the index.​
  1. Click Execute.​
Query an index​
  1. On the top menu bar of the Data interaction platform page, click the icon after Database and select the target database.​​icon after the database, select the target database.​
  1. In the visual area of the Data interaction platform, expand the Index, right-click the target index, and select Query index.​
  1. On the Session tab, click Execute.​
In the Execution result area, you can view the detailed index information.​
Delete an index​
warning​
  • The default index _id_ can not be deleted.​
  • Deleting the index of the system database is not allowed.​
  1. On the top menu bar of the Data interaction platform page, click the icon after Database and select the target database.​​icon after the database, select the target database.​
  1. In the visual area of the Data interaction platform, expand the Index, right-click the target index, and select Delete index.​
  1. In the Execute SQL dialog box, confirm deletion of the SQL statement for the index.​
  1. Click Execute.​
Edit the TTL value of an index​
When creating an index, you can edit the TTL value of the index if the TTL feature is enabled.​
  1. On the top menu bar of the Data interaction platform page, click theicon next to the database and select the target database.​
  1. In the visual area of the Data interaction platform, expand Collection and Index, click the icon after the target index, or right-click the target index, and Select Edit index TTL value.​
  1. On the Edit index TTL@Database tab, click Edit after the ExpireAfterSeconds Parameter to Modify the ExpireAfterSeconds Parameter value. The value range is [0, 2147483647], in second(s).​
  1. Click the ✅ icon to submit the modified data.​
  1. In the Execute SQL dialog box, confirm the SQL statement to be executed.​
  1. After confirming that the information is correct, click Execute.​
Related APIs​
​
API​
Description​
Call the DataExecCommands interfaceAPI to execute an SQL command.​
Call the DataSessionKeepAlive API to keep an SQL session alive.​
Call the DataCloseSession API to close an SQL session.​
Call the DataCancelExec API to cancel SQL execution.​
​
​
Last updated: 2025.11.10 20:18:15