November 17, 2010 at 2:30 pm
Hi Wayne,
WOW !!!!!!!!!, I have tested it and add an extra column and it works greatly , I'am very impressed with your skills !!!!
Thank you soooo much.
How do you think performance will on a file with 26 milj records ?? I will test it anyway to see myself but i like to here your comments on this
Regards
Dick Herberts
November 17, 2010 at 2:38 pm
Great job, Wayne!
That's the solution I had in mind... 😉
November 17, 2010 at 3:12 pm
@Dick: VERY IMPORTANT!!!
Based on your previous note "4. No clustered index yet " Do NOT run the code until you added a clustered index that supports the order the data need to be updated!!
I'd probably go with
CREATE UNIQUE CLUSTERED INDEX CX_testtable_ImportantForQuirkyUpdate
ON testtable (Category,Class,Location,RowNo)
Regarding performance:
I duplicated your data to build a Million-Row table (increasing Category value, actually 1.4Mill rows). Waynes code run in 3 seconds (excluding the final SELECT * which took another 17 sec). My system: Home PC with WinXP and SQL2K5.
Range as expected 😀
November 17, 2010 at 3:25 pm
LutzM (11/17/2010)
@Dick: VERY IMPORTANT!!!Based on your previous note "4. No clustered index yet " Do NOT run the code until you added a clustered index that supports the order the data need to be updated!!
I'd probably go with
CREATE UNIQUE CLUSTERED INDEX CX_testtable_ImportantForQuirkyUpdate
ON testtable (Category,Class,Location,RowNo)
I knew there was something I was going to add to my post - THANKS LUTZ!
Since you said that the PK was these same four columns - I just make the PK clustered. Since you have a multi-million row table, you will have to consider whether this is what you want to do or not.
Regarding performance:
I duplicated your data to build a Million-Row table (increasing Category value, actually 1.4Mill rows). Waynes code run in 3 seconds (excluding the final SELECT * which took another 17 sec). My system: Home PC with WinXP and SQL2K5.
Range as expected 😀
It took 3 whole seconds on your system? What'd you do, kick off a full system virus scan at the same time? :w00t:
Seriously, that's about the expected time for this to run.
Sorry I forgot to mention the clustered index - and again, thank you Lutz for picking up on that. Dick, that clustered index is supremely important for this to work correctly - otherwise, you'll end up with garbage.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
November 17, 2010 at 3:44 pm
Hi guys,
I'am testing the routine right now on a table with 26.000.000 records, tomorrow i will give the performance results.
Thanks very much for all your knowledge input
Have a nice evening and till tomorrow
November 17, 2010 at 3:49 pm
WayneS (11/17/2010)
...I knew there was something I was going to add to my post - THANKS LUTZ!
...
It took 3 whole seconds on your system? What'd you do, kick off a full system virus scan at the same time? :w00t:
Seriously, that's about the expected time for this to run.
...
My pleasure, mate! ()
Regarding performance: I double checked it using SET STATISTICS and Profiler. Both confirmed 2.6 sec.
I have to correct myself: The code didn't take whole 3 seconds. Just slightly more than 2, which is almost 1sec. And one sec doesn't count. So, the code finished instantly. :-D:-P
November 17, 2010 at 3:53 pm
Dick Herberts-320552 (11/17/2010)
Hi guys,I'am testing the routine right now on a table with 26.000.000 records, tomorrow i will give the performance results.
Thanks very much for all your knowledge input
Have a nice evening and till tomorrow
Did you add the clustered index before running it? (fingers crossed)
And you seriously don't have a minute to wait for the result? 😉
November 17, 2010 at 4:01 pm
LutzM (11/17/2010)
And you seriously don't have a minute to wait for the result? 😉
He doesn't think it will finish that fast... won't he be in for a surprise in the morning when he comes in.
If he didn't do that clustered index... due to the safety check, it won't complete if anything is being processed out of order. So all he'll have to do is build the index, then run again. (And if that new-fangled safety-check wasn't there, he'd be having to do a database restore to get the correct data!)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
November 17, 2010 at 10:03 pm
Don't be surprised if you find the method works on heaps, as well.
Nice job, though, guys. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
November 17, 2010 at 10:27 pm
Jeff Moden (11/17/2010)
Don't be surprised if you find the method works on heaps, as well.Nice job, though, guys. 🙂
Heh... we learned from the master! :w00t:
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
November 18, 2010 at 8:12 am
Hi Wayne and other techies,
Today i tested Wayne's routine on a table with 20.000.000 records. In total 6 columns are calculated and updated by Wayne's routine and it took 6 minutes. Before i ran the routine i created the clustered index. I have to add 8 more columns to calculate and then i will test it again. I have checked some results (random check) and it looked fine.
I have to say this again: I'am very impressed by this little nasty program who does the job so well. I never thought it was possible, but thanks to you clever guys and especially Wayne, i'am in heaven.
Thanks Wayne and all others for the input.
Regards,
Dick Herberts
November 18, 2010 at 5:19 pm
Dick Herberts-320552 (11/18/2010)
Hi Wayne and other techies,Today i tested Wayne's routine on a table with 20.000.000 records. In total 6 columns are calculated and updated by Wayne's routine and it took 6 minutes. Before i ran the routine i created the clustered index. I have to add 8 more columns to calculate and then i will test it again. I have checked some results (random check) and it looked fine.
I have to say this again: I'am very impressed by this little nasty program who does the job so well. I never thought it was possible, but thanks to you clever guys and especially Wayne, i'am in heaven.
Thanks Wayne and all others for the input.
Regards,
Dick Herberts
:blush:
Dick, I really do appreciate your kind words. And truth be told, it's things like this that keep many of us going.
However, to be truthful, I learned this from the guy I call "the master"... Jeff Moden. It would be worth your time to read all of his articles that he has written (and there are many other authors on this site with articles just as excellent as his - just search them out). You can find Jeff's articles here[/url].
Edit: But seriously... 6 minutes? It took that long? That must be one large table you're dealing with there!
Edit2: I would expect only a modest increase in the time to complete when adding the additional 8 columns... I would anticipate no more than 15 seconds total. It would be interesting to see how it ends up! Please keep us informed!
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
November 18, 2010 at 7:27 pm
WayneS (11/18/2010)
Dick Herberts-320552 (11/18/2010)
Hi Wayne and other techies,Today i tested Wayne's routine on a table with 20.000.000 records. In total 6 columns are calculated and updated by Wayne's routine and it took 6 minutes. Before i ran the routine i created the clustered index. I have to add 8 more columns to calculate and then i will test it again. I have checked some results (random check) and it looked fine.
I have to say this again: I'am very impressed by this little nasty program who does the job so well. I never thought it was possible, but thanks to you clever guys and especially Wayne, i'am in heaven.
Thanks Wayne and all others for the input.
Regards,
Dick Herberts
:blush:
Dick, I really do appreciate your kind words. And truth be told, it's things like this that keep many of us going.
However, to be truthful, I learned this from the guy I call "the master"... Jeff Moden. It would be worth your time to read all of his articles that he has written (and there are many other authors on this site with articles just as excellent as his - just search them out). You can find Jeff's articles here[/url].
Edit: But seriously... 6 minutes? It took that long? That must be one large table you're dealing with there!
Edit2: I would expect only a modest increase in the time to complete when adding the additional 8 columns... I would anticipate no more than 15 seconds total. It would be interesting to see how it ends up! Please keep us informed!
Heh... no... not a master. If I were, I'd have been the one to figure out the on-the-fly safety check. :blush: Gotta give Paul White the credit for figuring it out and Tom Thompson the credit for making it a bit more bullet proof. I believe I've figure out how to add a similar safety check to 2k so maybe I'm a brown belt. 😛
The reason why the update is taking so long is because the tipping point (every computer has one) has probably probably been reached. It would probably only take 3 seconds per million rows if the UPDATE were divided into logical sections of 2 million rows each.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 19, 2010 at 12:51 pm
Hi guys,
today i added 8 extra columns (in total there 14 columns now which are calculated) with wayne's routine. The test i did today was on a table with 21.000.000 records. it took a couple of minutes more (in total 11 minutes) which is for me fantastic.
Regards,
Dick Herberts
November 19, 2010 at 3:47 pm
Thanks for the feedback Dick. Glad you're pleased with it!
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 15 posts - 16 through 29 (of 29 total)
You must be logged in to reply to this topic. Login to reply