Performance Firebird性能:更新/选择verus Insert/选择last

Performance Firebird性能:更新/选择verus Insert/选择last,performance,firebird,Performance,Firebird,我必须保持帐户余额的最新状态,记录变化,并使用它 在我看来,选择是: 把它放在一排 使用触发器将更改保存到单独的表中 使用select | update进行更新 使用表中的简单选择来访问值 另一种选择是: 将值保存在单独的表中 使用“选择最后一个”和“插入”来实现更新 使用单独表中的Select Last访问该值 有人知道哪个更快吗?里面有很多吗 史蒂夫你的提议似乎太复杂了。。。 我建议做另一件事: 我会有两个主-细节关系的表。 在细节中,我将插入行,其触发器将更新主表 balance (acc

我必须保持帐户余额的最新状态,记录变化,并使用它

在我看来,选择是:

  • 把它放在一排
  • 使用触发器将更改保存到单独的表中
  • 使用select | update进行更新
  • 使用表中的简单选择来访问值
  • 另一种选择是:

  • 将值保存在单独的表中
  • 使用“选择最后一个”和“插入”来实现更新
  • 使用单独表中的Select Last访问该值
  • 有人知道哪个更快吗?里面有很多吗


    史蒂夫

    你的提议似乎太复杂了。。。 我建议做另一件事: 我会有两个主-细节关系的表。 在细节中,我将插入行,其触发器将更新主表

    balance (account, amount, ...)
    balance_detail (account, amount, ...)
    
    balance_detail_after_insert
    begin
        update master
        set amount = amount + new.amount
        where account = new.account;
    end
    
    balance_detail_after_update
    begin
        update master
        set amount = amount + new.amount - old.amount
        where account = new.account;
    end
    
    balance_detail_after_delete
    begin
        update master
        set amount = amount - new.amount
        where account = new.account;
    end
    

    在任何更改之后,您只需关闭/打开主表即可刷新数据。

    我认为您的问题需要更详细的信息,因为就目前情况而言,我认为它太模糊了。例如:我不知道你所说的“使用选择|更新来进行更新”是什么意思,或者“最后选择”是什么意思。