Node.js 中的数据库查询分析
DB Query profiling in Node.js
我正在使用 express
构建一个 json API(好吧,也许会移动到 koa
)。我将数据存储在 PostgreSQL 数据库中,并使用 pg-promise
从中获取数据(async/await
通过 babel)。
我是 node.js 的新手,我找不到有关该环境中性能测量的任何信息。
具体来说:
module.exports.get_hierarchy = async function () {
const rows = await postgres.any('SELECT id, parent, title, permission FROM heading');
var result = [];
// some black magic goes here...
return result;
}
我想知道(以编程方式如果可能)消耗了多少时间SELECT
。 (不是从构造到解析的时间承诺,可以通过取两个时间戳来实现,而是数据库服务器处理查询实际消耗的时间)。
这能实现吗?如果是,怎么做?
我正在使用 express
构建一个 json API(好吧,也许会移动到 koa
)。我将数据存储在 PostgreSQL 数据库中,并使用 pg-promise
从中获取数据(async/await
通过 babel)。
我是 node.js 的新手,我找不到有关该环境中性能测量的任何信息。
具体来说:
module.exports.get_hierarchy = async function () {
const rows = await postgres.any('SELECT id, parent, title, permission FROM heading');
var result = [];
// some black magic goes here...
return result;
}
我想知道(以编程方式如果可能)消耗了多少时间SELECT
。 (不是从构造到解析的时间承诺,可以通过取两个时间戳来实现,而是数据库服务器处理查询实际消耗的时间)。
这能实现吗?如果是,怎么做?