-
SubQuery Performance
Hi All,
I have a poor performance SQL as following. The table has about 200M records, each employee have average 100 records. The query lasts about 3 hours. All I want is to update the flag for highest version of each client's record. Any suggestion is welcome!
Thanks,
Mike
====SQL===========
update empTbl A
set flag=1
where
rec_ver =
( select max(rec_ver)
from empTbl
where empNo = A.empNo)
===Table empTbl=====
empTbl
{
int empNo;
int flag;
char[256] empDesc;
int rec_ver;
}
-
Please do tell there is an index on empTbl.empNo
Post execution plan, please.
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|