DocumentDB slow in LIMIT_SKIP stage.

0

Hi. I was used documentDB 4.0.0 version.

It is my code. (This function make Numeric ID sequence)

  private async generatePushMessageSequence(): Promise<number> {
    const result = await this.sequenceModel
      .findOneAndUpdate(
        { _id: 'XXX' },
        { $inc: { sequence: 1 } },
        { new: true, upsert: true },
      )
      .exec();
    return result.sequence;
  }

But sometimes this operation is too slow

{"op":"command","ts":1644926941441,"ns":"test.xxx",
"command":{
	"findAndModify":"xxx",
	"query":{"_id":"XXX"},
	"remove":false,
	"new":true,
	"upsert":true,
	"fields":{},
	"update":{"$inc":{"sequence":1}},"lsid":{"id":{"$binary":"XXX","$type":"4"}},"$db":"test"},

	"nMatched":1,
	"nModified":1,
	"protocol":"op_query",
	"millis":1472,
	"planSummary":"IXSCAN",
	"execStats":{
		"stage":"UPDATE",
		"nReturned":1,
		"executionTimeMillisEstimate":0,
		"inputStage":{
			"stage":"LIMIT_SKIP",
			"nReturned":"1",
			"executionTimeMillisEstimate":"1441.544",
			"inputStage":{
				"stage":"IXSCAN",
				"nReturned":"1",
				"executionTimeMillisEstimate":"2.736",
				"indexName":"_id_",
				"direction":"forward"
			}	
		}
	},
}

In "LIMIT_SKIP" stage, 1441ms needed.

I suspecting mognoose 'findOneAndUpdate' function called documentDB 'findAndModify' && limit(1)' query.

But I cannot understand, 'Why too slow in LIMIT_SKIP stage.'. Bcz, nReturn is already only 1 doc.

Can I get some guide for this slow situation?

asked 2 years ago95 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions