Simulate slow query in mongodb?

前端 未结 3 1720
野性不改
野性不改 2021-02-15 23:35

Does MongoDb have anything like MySql\'s SELECT SLEEP(5); ?

I can see some internal sleep function that would pause the whole server, but I need to pause ju

3条回答
  •  深忆病人
    2021-02-16 00:17

    From the mongo shell you can do sleep( ms ), eg sleep for 5 seconds before running a query:

    > sleep(5000); db.collection.find(..);
    

    This doesn't pause the current query, but does pause execution on that connection for the specific number of milliseconds before continuing with the next statement (which is equivalent to a select sleep(5) in MySQL).

提交回复
热议问题