Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
trento
Starting Member
13 Posts |
Posted - 2009-08-10 : 18:20:39
|
| I’m looking into existing daily process in loop like this:1. Read input seq#,2. Select into cursor multiple rows from THIST with ORDER3. Fetch cursor till the end4. Update THIST.FLAG5. Commit6. Close cursorIt’s on SQL 8.0 and it brings some performance issues running very slow, so I’m thinking how I can tune it to run faster. THIST holds data for 10 days, so I’m thinking to work on view VHIST = SELECT * FROM THIST WHERE DATE=today, then I can get rid of ORDER in main select.And probably get rid of #5 commit.Not sure how bad update is, anybody can suggest what else Pro’s doing .Thanks to all.T |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2009-08-10 : 22:37:25
|
| I can't begin to imagine why with your cursor solution you go to the end rather than sorting it in descending order and fetching the first one. Anyway, this should do more or less the same depending on the data:update THIST set flag='value' where date=@todayIf you cannot uniquely identify the 'last one' (by using 'today' in the above example) then you need to think again using row_number().You will need the commit somewhere of course. |
 |
|
|
|
|
|