Link to home
Start Free TrialLog in
Avatar of dteshome
dteshome

asked on

Query that immobilizes the dev server

Please help figure out why query is making server "non-responsive" extreemly slow, have to reboot everytime I run this update stmt that a developer is running in Dev.


--
Facts: # of recs in tables
select * from themls_offices -- 93414
--
SELECT COUNT(*) -- 69684
from [devdb.helios.themls.com].[mls].[dbo].[all_carets_offices]  ACO

--
Is the update below checking/reading 6,557,849,628
(69684 X 70202 recs)??
I say this because it appears to be the case from the query and when run, it brings down the dev server (extreemly slow, non responsive)

update themls_offices
set CARETS_OfficeID = AgentOfficeID
from [devdb.helios.themls.com].[mls].[dbo].[all_carets_offices] as ACO
where firmCode = cast(ACO.MlsOfficeid as varchar(30))
--
--**I replaced above query by one below - is it equivalent? (FirmCode and CARETS_OfficeID  belong to themls_offices ...)
update themls_offices
set CARETS_OfficeID = aco.AgentOfficeID
from [devdb.helios.themls.com].[mls].[dbo].[all_carets_offices]  ACO
inner join themls_offices MO
on MO.firmCode = cast(ACO.MlsOfficeid as varchar(30))
--*
I expected  69684 recs to be update (see below)
However, the query is taking over 30 min to run. still running
(maybe becasue it is going accross servers - linked server ??)

SELECT COUNT(*) -- 69684
from [devdb.helios.themls.com].[mls].[dbo].[all_carets_offices]  ACO
inner join themls_offices MO
on MO.firmCode = cast(ACO.MlsOfficeid as varchar(30))


--*
ASKER CERTIFIED SOLUTION
Avatar of Racim BOUDJAKDJI
Racim BOUDJAKDJI
Flag of Algeria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dteshome
dteshome

ASKER

Thank you both (Racimo and Lcohan).  I have been sidtracked with Prod issues; I will do what you sugegsted and report back .
Tx
Dan