Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.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
Node.js node js和postgresql降低了Cpu使用率_Node.js_Postgresql - Fatal编程技术网

Node.js node js和postgresql降低了Cpu使用率

Node.js node js和postgresql降低了Cpu使用率,node.js,postgresql,Node.js,Postgresql,在Node js中,我使用的是postgresql数据库。当我在DB中插入大量数据时,CPU使用率将达到10%到15% 我想将cpu使用率从5%降低到6% function execute(count) { step(0); function step(i) { if (i < count) { client.query("INSERT INTO test1 (firstname, lastname) values($1, $2)",

在Node js中,我使用的是postgresql数据库。当我在DB中插入大量数据时,CPU使用率将达到10%到15%

我想将cpu使用率从5%降低到6%

function execute(count) {
    step(0);
    function step(i) {
        if (i < count) {
            client.query("INSERT INTO test1 (firstname, lastname) values($1, $2)", ['Ronald', 'McDonald'], function (err, respose) {
              //  console.log(respose);
                console.log("insert");
                step(++i);
            });
        }
        else {
            selectQuery();
        }
    }
}
函数执行(计数){
步骤(0);
功能步骤(i){
如果(i
PostgreSQL在其配置文件中有一个可以缓存数据的指令

shared_buffers=3GB For 16 GB of RAM

该值基于系统RAM的数量,该数量应为RAM的20%

什么是“cpu使用率5”?您的数据来自哪里?Postgres支持适当的批量插入(例如,请参见)。