I want to find an account by name (in a MongoDB collection of 50K accounts)
我们用绳子找到In the usual way:个
db.accounts.find({ name: 'Jon Skeet' }) // indexes help improve performance!
How about with regular expression? Is it an expensive operation?
db.accounts.find( { name: /Jon Skeet/ }) // worry! how indexes work with regex?
编辑:
According to WiredPrairie:
db.accounts.find( { name: /^Jon Skeet/ }) // indexes will help!'