Skip to content

How to create custom MongoDB indexes #6280

Open
@n-tanaka-idcf

Description

  • I am trying to use ST2 REST API to get executions.
    • The request is as follows:
curl -s \
  -H 'Content-Type: application/json'
  -H "St2-Api-Key: ${ST2_API_KEY}"\
  -k 'localhost:80/api/v1/executions?offset=0&limit=100&parent=null'
  • This request takes about 5 to 8 seconds in our environment.

  • I checked the mongoDB's execution plan and found that the sorting process took a long time.

  • I created a following index to speed up the sorting process.

db.action_execution_d_b.createIndex({ parent: 1, start_timestamp: -1, 'action.ref': 1 }, { background: true })
  • The index has improved request speed. However, the created index is automatically deleted.
2024-11-15T03:22:50.069+0900 I ACCESS   [conn965898] Successfully authenticated as principal st2admin on st2 from client xxx.xxx.xxx.xxx:50468
2024-11-15T03:22:50.103+0900 I COMMAND  [conn965898] CMD: dropIndexes st2.action_execution_d_b
  • Then I have two questions
    • Is it a specification that user-created index is deleted?
    • Is there a way to prevent user-created index from being automatically deleted?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions