作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试使用 pg gem 获取查询的时间。我看到了文档,但没有找到任何东西。我想知道是否有类似 query.time
的东西。
我在 ~/.psqlrc
中添加了 \timing
,因此该命令默认处于事件状态。如果我在 Postgres 控制台中编写查询,则时间处于事件状态。
这是代码:
conn = PGconn.open(:dbname => 'my_db')
query=conn.exec('SELECT * from some_table')
puts query.num_tuples -> this work
puts query.time -> undefined method
我需要测量 Postgres 本身的时间,我不能使用 Ruby 的 Time 类。
最佳答案
试试这个,因为它应该会返回时间。
puts conn.exec("EXPLAIN ANALYZE SELECT * FROM some_table").values
关于ruby - 如何从 PgSQL DB 获取时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35905793/
我是一名优秀的程序员,十分优秀!