Subject | Re: Slow Update |
---|---|
Author | Adam |
Post date | 2005-12-05T23:35:27Z |
--- In firebird-support@yahoogroups.com, "Maxisoft - Luciano
Enzweiler" <enzweiler@s...> wrote:
records.
not null) and (T2.FILTRO = 1)))
Your select example contains a fixed list, the update uses a query in
the in statement, which is executed for every record.
try the following, it may help.
update TABLE1 T1 set
T1.MARCA = 0
where
(T1.MARCA = 1) and
not Exists(
select T2.CODREF
from TABLE2 T2
where (T2.CODREF is not null
and T1.CODTB <> T2.CODREF ) and (T2.FILTRO = 1))
)
Adam
Enzweiler" <enzweiler@s...> wrote:
>there seem to be no reason for that.
> Hi.
>
> I made an update SQL but it takes too much time to execute, and
>fields are integers, but none is indexed. Both tables have about 2000
> The update is like this one:
>
> The field T1.CODTB is the Primary Key of TABLE1 and all the other
records.
>(T1.CODTB not in (select T2.CODREF from TABLE2 T2 where (T2.CODREF is
> update TABLE1 T1 set T1.MARCA = 0 where (T1.MARCA = 1) and
not null) and (T2.FILTRO = 1)))
Your select example contains a fixed list, the update uses a query in
the in statement, which is executed for every record.
try the following, it may help.
update TABLE1 T1 set
T1.MARCA = 0
where
(T1.MARCA = 1) and
not Exists(
select T2.CODREF
from TABLE2 T2
where (T2.CODREF is not null
and T1.CODTB <> T2.CODREF ) and (T2.FILTRO = 1))
)
Adam