小编bma*_*ies的帖子

如何在 pgsql 9.1 中执行返回空值的过程?

如果我使用 pgsql 命令在文件中执行以下内容,它会抱怨需要使用“perform”调用该过程。但是当我尝试使用 perform 时,它告诉我未定义 perform 。解决办法是什么?

create or replace function waitris() returns void as 
$$
declare
    cnt integer;
begin
    loop
        select count(*) into cnt from taskflag where taskid = 'rdfdb' and state != 2;
        if cnt = 0 then   
            exit;
        end if;
        select pg_sleep(1);
    end loop;
end;
$$ 
language plpgsql;

select waitris();
Run Code Online (Sandbox Code Playgroud)

postgresql

8
推荐指数
1
解决办法
2万
查看次数

mongodb 在记录更新时告诉我什么?

在将大量数据推送到 mongo 的大型程序几分钟后,我的日志开始显示(我猜)每次更新的消息。这看起来非常嘈杂,是否有什么特殊原因需要这样做?

Tue Jun  5 14:32:37 [conn3] update benchmark.entity  
 query: { corefEntityId: "45-LOCATION" } 
 update: { $set: { corefEntityId: "45-LOCATION", type: "Location" },
 $push: { indocs: { docid: "cfcc403b-714f-4c5d-8507-ccb5b6354654", 
   ordinal: 26, label: "United States", mentions: [ "United States" ] } }, 
   $addToSet: { allMentions: { $each: [ "United States" ] } }, 
   $inc: { documentCount: 1 } } 116ms
Run Code Online (Sandbox Code Playgroud)

作为一个可能更容易回答的脚注,我想知道:与将普通插入到内部文档的其他集合中作为顶级文档相比,添加到某些内部文档的“upsert”是否更快或更慢?

mongodb upsert

6
推荐指数
1
解决办法
1671
查看次数

加快 postgresql 中的删除速度

我想出了:

drop table if exists idtemp;
create temp table idtemp as 
      select documentid from taskflag where taskid='coref' and state = 2 
         order by statechanged asc limit howmany;
create unique index on idtemp(documentid);

-- trim taskflag to the first N docs ordered by coref.
delete from taskflag where documentid not in (select documentid from idtemp) ;
Run Code Online (Sandbox Code Playgroud)

当任务标志中有 120k 条记录而我保留 10k 条记录时,速度非常慢。

任务标志看起来像:

\d taskflag
                Table "public.taskflag"
    Column    |            Type             | Modifiers 
--------------+-----------------------------+-----------
 documentid   | character varying(64)       | not null
 taskid       | …
Run Code Online (Sandbox Code Playgroud)

postgresql

3
推荐指数
1
解决办法
1169
查看次数

标签 统计

postgresql ×2

mongodb ×1

upsert ×1