开发者

Updating where id in stored procedure - enormous amount of fetches

开发者 https://www.devze.com 2023-02-27 01:20 出处:网络
UPDATE TABLE SET SOMETHING = 1 WHERE ID IN (SELECT ID FROM STORED_PROCEDURE) Records in TABLE = 2100 Records from stored procedure = 50
UPDATE TABLE SET SOMETHING = 1 WHERE ID IN (SELECT ID FROM STORED_PROCEDURE)

Records in TABLE = 2100

Records from stored procedure = 50

This statement cousing enormous amount of fetches (31M!) on firebird 2.5 server. Why? Shouldn't it first select id's from stored procedure and then put it in where clau开发者_如何学运维se? What should I do to make it work?


Try something like this:

declare variable myid integer;    
begin
    for
        select id from stored_procedure into :myID
    do begin
      update table set something = 1 where table.id = :myID;
    end
end
0

精彩评论

暂无评论...
验证码 换一张
取 消