Creating an Index
Indexes can greatly improve query efficiency. If there are no indexes, each file in the collection must be scanned and the records that meet the query conditions must be selected when data is read. If the amount of data is large, querying an entire collection may take dozens of seconds or even minutes.
Procedure
- Log in to the DAS console.
- Click in the upper left corner and select a region and project.
- Click in the upper left corner, and under Databases, click Data Admin Service.
- In the navigation pane on the left, choose Development Tool.
You can also click Go to Development Tool on the overview page.
- Locate the DB instance that you want to log in to and click Log In in the Operation column.
- On the top menu bar, choose Database Management.
- On the displayed page, click before the collection name.
Figure 1 Expanding the collection list button
- Click New Index.
Figure 2 Creating an index
- On the displayed page, configure basic parameters.
Figure 3 Specifying index information
Table 1 Parameter description Parameter
Description
Database
Selected database by default. You can also enter a database name. After the index is created, the system automatically creates a database with the name you entered.
Collection
Selected collection by default. You can also enter a collection name. After the index is created, the system automatically creates a collection with the name you entered.
Index
Index name, which is user-defined.
Advanced Settings
- Background: indicates the backend mode for creating indexes.
Selecting Background is recommended. If this option is not selected, the database will be locked.
- Unique: specifies whether the created index is unique.
- Sparse: does not enable indexes for field data that does not exist in the document.
Index
Click Add and enter a name and type to add an index.
- Background: indicates the backend mode for creating indexes.
- (Optional) on the Text Option page, select information such as the index version and default language.
- (Optional) on the Collation page, set the sorting rule.
- After the configurations are complete, click Save.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot