Subject | UPDATE: what am I doing wrong? |
---|---|
Author | garyjones_mvm |
Post date | 2003-07-18T16:10:12Z |
I have a query regarding the speed of using UPDATE in Firebird. I'm
trying to update one table will values looked-up from another.
Here's the example I have:
Table: People
Fields: id, name, amount
(5000 records)
Table: Amount
Fields: id, amount
(8000 records)
Stored Procedure:
begin
for
SELECT a.id,a.amount
from amount a
into
:v_id,
:v_amount
do begin
UPDATE people p
SET amount = :v_amount
WHERE
p.id = :v_id;
end
end
The above procedure is taking over two minutes to run with a local
server on a 2.6MHz Pentium4 PC with 512Mb RAM. I'm not convinced
that this is the best Firebird can do.
Significantly perhaps, the performance monitor in IBExpert reports
that the table PEOPLE is read around 40 million times in executing
the procedure. (It's probably no coincidence that 40
million=5000x8000).
So, what am I doing wrong, and how can I get my UPDATEing to work
faster?
Thanks.
Gary
trying to update one table will values looked-up from another.
Here's the example I have:
Table: People
Fields: id, name, amount
(5000 records)
Table: Amount
Fields: id, amount
(8000 records)
Stored Procedure:
begin
for
SELECT a.id,a.amount
from amount a
into
:v_id,
:v_amount
do begin
UPDATE people p
SET amount = :v_amount
WHERE
p.id = :v_id;
end
end
The above procedure is taking over two minutes to run with a local
server on a 2.6MHz Pentium4 PC with 512Mb RAM. I'm not convinced
that this is the best Firebird can do.
Significantly perhaps, the performance monitor in IBExpert reports
that the table PEOPLE is read around 40 million times in executing
the procedure. (It's probably no coincidence that 40
million=5000x8000).
So, what am I doing wrong, and how can I get my UPDATEing to work
faster?
Thanks.
Gary