Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance mongodb正则表达式查询性能问题_Performance_Mongodb_Mongodb Query_Query Performance_Mongo Java - Fatal编程技术网

Performance mongodb正则表达式查询性能问题

Performance mongodb正则表达式查询性能问题,performance,mongodb,mongodb-query,query-performance,mongo-java,Performance,Mongodb,Mongodb Query,Query Performance,Mongo Java,我正在使用MongoJava客户端。与同一文档的普通查询相比,使用正则表达式时,我可以看到x100个查询速度较慢。 所有文档都在查询中使用的字段上建立索引。 在mongodb中使用正则表达式进行搜索时,如何提高查询性能?通过编写更智能的正则表达式,您可能可以稍微提高性能。但相比之下,regex操作总是很慢。索引对您没有帮助,正则表达式操作永远不能使用索引。发布一些您正在执行的缓慢查询和示例文档@Tomalak在某些情况下,索引对regex@joao很有用,只有一种情况:当您的模式是前缀模式时。很

我正在使用MongoJava客户端。与同一文档的普通查询相比,使用正则表达式时,我可以看到x100个查询速度较慢。 所有文档都在查询中使用的字段上建立索引。
在mongodb中使用正则表达式进行搜索时,如何提高查询性能?

通过编写更智能的正则表达式,您可能可以稍微提高性能。但相比之下,regex操作总是很慢。索引对您没有帮助,正则表达式操作永远不能使用索引。发布一些您正在执行的缓慢查询和示例文档@Tomalak在某些情况下,索引对regex@joao很有用,只有一种情况:当您的模式是前缀模式时。很可能OP的模式不是这样。@Tomalak您可能应该删除第一条评论。说正则表达式操作永远不能使用索引是错误的。@Tomalak当然,都是真的。但说他们永远不能使用索引是言过其实了。