我尝试使用 rbenv 的 ruby-build 插件构建 Ruby 3.2,但遇到一些奇怪的编译错误:
\ncompiling bignum.c\nIn file included from vm_core.h:164:0,\n from iseq.h:14,\n from mini_builtin.c:3,\n from miniinit.c:51:\nthread_pthread.h:109:39: error: expected \xe2\x80\x98=\xe2\x80\x99, \xe2\x80\x98,\xe2\x80\x99, \xe2\x80\x98;\xe2\x80\x99, \xe2\x80\x98asm\xe2\x80\x99 or \xe2\x80\x98__attribute__\xe2\x80\x99 before \xe2\x80\x98struct\xe2\x80\x99\n RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;\n ^\nIn file included from iseq.h:14:0,\n from mini_builtin.c:3,\n from miniinit.c:51:\nvm_core.h: In function \xe2\x80\x98rb_current_execution_context\xe2\x80\x99:\nvm_core.h:1864:34: error: \xe2\x80\x98ruby_current_ec\xe2\x80\x99 undeclared (first use in this function)\n rb_execution_context_t *ec = ruby_current_ec;\n ^\nvm_core.h:1864:34: note: each undeclared identifier is reported only once for each function it appears in\nRun Code Online (Sandbox Code Playgroud)\n这是完整的日志:https://gist.github.com/tycooon/c077a1d99299469bd86131211c565ff7。
\nRuby …
我在一个带有索引"名称"字段的集合中有150万个文档.查询db.things.find({name: /^foo/i})大约需要5秒,这非常慢.具有相同记录的类似MySQL表SELECT * FROM things WHERE name LIKE 'foo%'在不到10毫秒内执行.
mongo的解释:
db.things.find({name: /^foo/i}).limit(10).explain()
{
"cursor" : "BtreeCursor name_1 multi",
"nscanned" : 325730,
"nscannedObjects" : 10,
"n" : 10,
"millis" : 4758,
"nYields" : 89,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"name" : [
[
"",
{
}
],
[
/^foo/i,
/^foo/i
]
]
}
}
Run Code Online (Sandbox Code Playgroud)
那么,正则表达式查询是在蒙戈慢还是我做错了?